#### Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

# How to make actor rotate only 1 time

Posts: 57Member, PRO

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.

• Posts: 1,478Member, PRO
edited January 18

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

• Posts: 57Member, PRO

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!

@Icebox said:
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

• Posts: 402Member
edited January 19

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.)

• Posts: 57Member, PRO

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:

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.)

• Posts: 402Member

Something like this.