Generating A Random Number Within A Range

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

  • gyroscopegyroscope I am here.Posts: 6,598
    edited February 2014 Accepted Answer

    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

  • MattmakesgamesMattmakesgames Member Posts: 9
    Ah brilliant! Can't believe I didn't see the random function before! Many thanks and thanks for telling me about the manual, I'll take a look in there next time I get stuck.
Sign In or Register to comment.