How to make actor rotate only 1 time
sinbot
Member Posts: 232
I have an actor that pursues the hero based on a magnitude attribute (when hero gets within x amount pixels, enemy moves to attack). some of these enemies have to rotate 1 time to position themselves properly which works fine. Problem is that they rotate every time the proximity rule becomes true which causes the enemy to then rotate every time the rule applies (sometimes rotating it upside down). I'm trying to find a way to make the enemy rotate only 1x in spite of the magnitude rule. I know an integer attribute is probably needed but not sure how to set it up given the magnitude rule that is in place.
Comments
You can probably use a nested rule
wrap your rotate behaviour inside the rule with another rule
if self.rotation is not equal to 180
rotate to angle 180
test and tell me if it works
i tried nesting the rule a few diff ways (just in case i wasn't doing it right). altho it didn't work the key was the rule you suggested which got me thinking about the solution differently. so tweaked it a bit and this worked!
You need a counter(#ofTimes) that counts the number of times the Distance <400. Make the count control determine if the rotation behaviour happens or not.
(Initially #ofTimes = 0)
When Distance < 400
ofTimes = #ofTimes + 1
When Distance < 400 and #ofTimes = 1
(Do Rotation behaviour.)
That's initially what I was wanting to do. Is the (#ofTimes) a game integer attribute? Could you post a screenshot of what it would look like?> @Valan said:
Something like this.