Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I'm trying to create a pseudo turn based battle system in the Unreal Engine (think Final Fantasy style).

I'm trying to avoid the Enemies and the players attacking while another animation is in progress. I thought the most simple solution is to have a flag somewhere that the player controllers check before starting an animation, and set it to a value before they start, and then reset it when they've finished.

However, I could see this leading to race conditions if two controllers (AI or player) try to access the variable at the same time, then both start their animations.

If I was writing this in Java I'd obviously use synchronized methods, but I haven't come across anything like that in UnrealScript. Is there another way to avoid this? Its probably not the end of the world, as its a pretty unlikely occurance, but I'd like to try and avoid it completely if possible.

share|improve this question
    
"pseudo turn based?" It's either turn based or it's not, don't complicate your life =) Maik Semder left your answer below, and a good one it is. –  Patrick Hughes Feb 15 '12 at 18:32
add comment

1 Answer 1

up vote 5 down vote accepted

obviously use synchronized methods, but I haven't come across anything like that in UnrealScript

Unreal script is only allowed and runs only in the main-thread, so there is no need to add synchronization objects to Unreal Script. In other words, two lines of script code can never access a variable at the same time from different threads, so no worries about race conditions in Unreal Script :)

share|improve this answer
    
Thanks, makes things much simpler :) –  Tom Feb 16 '12 at 12:47
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.