#### Howdy, Stranger!

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

# How can I randomize two numbers in "direction" slot

Posts: 136Member, PRO
edited January 9

My actor spawns and I want him to either go left or right (0, 180)... how do I randomize this in the move behavior?

• Posts: 396Member, BASIC

One way that would work,

Create a new Index attribute. Make it change to a random value between 0 and 1.
Random(0,1)

Then have two seperate rules for the actor that is spawned.

When Index Attribute is equal to 0.
Then Move direction 0.

When Index Attribute is equal to 1
Then Move direction to 180.

Hope that helps,

• Posts: 396Member, BASIC
edited January 9

Or,

Create a new Index attribute. Make it change to a random value between 0 and 1.
Random(0,1)

Then have a move behaviour directly below. In the Direction section, open up the expression editor and enter in the following.

(Index.Attribute*==0)and(0)or(180)

*You will need to select the the Index attribute. Not the word.

• Posts: 396Member, BASIC

Or,

If you just want to use the move behaviour,

You could just add the following into the direction section expression editor:

(Random(0,1)==0)and(0)or(180)

• Posts: 136Member, PRO

@Two.E Thanks so much!!! it worked. I used the first one.

• London, UK.Posts: 12,832Member
edited January 9

You can also set the direction to:

Random(0,1)*180

• Posts: 396Member, BASIC

@Socks said:
You can also set the direction to:

Random(0,1)*180

I knew there was a simple way. Almost got there on my own!

• London, UK.Posts: 12,832Member
edited January 9

@Two.E said:

@Socks said:
You can also set the direction to:

Random(0,1)*180

I knew there was a simple way. Almost got there on my own!

It's one of those questions with several million solutions !

You could also do it with the speed . . . .

random(((0,1)`*`2)-1)`*`300