Generating A Random Number Within A Range
Mattmakesgames
Member Posts: 9
Hey everyone, I'm trying to spawn an actor randomly along an axis everytime the scene resets and I was planning to do it by generating a random number within a range but I'm not sure how to do that? Unless there is an easier way? Thanks!
Best Answer
-
gyroscope I am here.Posts: 6,598
Hi @Mattmakesgames
You can use the random function via the expression editor, so put in an actor at the side of the screen your Spawn behaviour. This will then spawn when you reset the scene as you want.
Now, in the x position in that behaviour, click on the "e" symbol that'll take you to the expression editor.
In the drop down menu next to Insert function, choose random. Then in place of min and max, put your minimum and maximum x coordinates. An example:
random(50,430)
Have you gone through the GameSalad Creator manual? It's really useful, especially if you're new to the software.
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
Answers