How to randomly alternate an actor´s position between three predefined spots on the Y axis?
I´m trying to create a game pattern in which the actor randomly appears on one of three possible positions every five seconds...any suggestions. Thanks a lot.
Best Answers
-
BenMakesGames Posts: 85
Just to Clarify, Are you spawning an actor at one of 3 possible positions or are you moving an actor to one of 3 random positions?
The process I would use would be similar for both.
**Part 1**
You would need to create an "real" attribute. Eg .Call it Actor_Y_Location.
This attribute would have a number between 1-3
**Part 2**
Now, lets say your actor is spawning.
Your actor would need a few "if statements". It would be as follows
If "Actor_Y_Location" is equal to 1;
Change Actor.Location.Y to 50
If "Actor_Y_Location" is equal to 2;
Change Actor.Location.Y to 100
If "Actor_Y_Location" is equal to 3;
Change Actor.Location.Y to 200
**Part3**
Now, add a "change attribute" into the actor so every time the actor is spawned the Actor_Y_Location will change
Eg. Change Attribute "Actor_Y_Location" to Random(1,3)
Then add a timer that says "after 5 seconds" spawn "actor".
The GSTimer example is probably best for maintaining performance.
Hope this Helps. -
TheGabfather Posts: 633
@applucinate Then you can use Interpolate instead of Change Attribute to make it scroll.
Answers