Trigger random scene.

CaptFinnCaptFinn Member Posts: 1,828
edited November -1 in Working with GS (Mac)
How would I go about making a "on touch" leave current scene and randomly pick another scene? So if I have 45 Scenes and Im currently on scene 17. I touch a button actor and it randomly pics one of the 45 scenes.

Comments

  • quantumsheepquantumsheep Member Posts: 8,188
    You'd have to generate a random number.

    On touch, change attribute RANDOM to Random (1,45)

    If RANDOM = 1
    Change scene to scene 1

    If RANDOM = 2
    Change scene to scene 2

    etc etc

    Hope that helps,

    QS :D

    Dr. Sam Beckett never returned home...
    Twitter: https://twitter.com/Quantum_Sheep
    Web: https://quantumsheep.itch.io

  • mynameisacemynameisace Hull, UKMember Posts: 2,484
  • CaptFinnCaptFinn Member Posts: 1,828
    Ace what you sent me works. But I dont understand it. Because no where does it say if random is 2 do this if random is 3 do this if random is 4 do this. every actor on every scene say if 1 make 0 and after timer got o scene 1. Nothing says go to scene 2 or to scene 3 or scene 4. Its wierd.
  • quantumsheepquantumsheep Member Posts: 8,188
    Look in the otherwise part of the rule.

    QS :D

    Dr. Sam Beckett never returned home...
    Twitter: https://twitter.com/Quantum_Sheep
    Web: https://quantumsheep.itch.io

  • CaptFinnCaptFinn Member Posts: 1,828
    yes but it only goes to 2. nothing says if 3 or if 4
  • CaptFinnCaptFinn Member Posts: 1,828
    ok why are there so many " otherwises " why not just a list of rules. why are they subset to otherwises?
  • CaptFinnCaptFinn Member Posts: 1,828
    I could see this being a easyway to drag all in one to my behaviors
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    Hi Jeff, this'll be more Rules needed than you might think. First, one problem to overcome is to make sure that the randomly picked scene isn't the one the user is already on. I think there might be some expressions/algorithm for this floating about although I don't know it - my solution to that doesn't involve much more Rules anyway. Another thing to point out is when you've got your random number in it's attribute, there's no shortcut to putting "when FinalPick = 1, Change Scene go to scene 1; when FinalPick = 2, Change Scene go to scene 2, etc; all the way to scene 45. But the main work is doing this once, with a small amendment in each case depending on what scene you're on.

    • Make 4 game integer attributes, Pick1, Pick2, PickChoice and FinalPick

    • OK, in your Prototype Actor Button in the Inspector Actors section, put the following to pick a random scene and to avoid picking the same scene that you're on:

    Rule: When Actor receives event touch is pressed
    -A- Change Attribute game.pick1 to random(1,2)
    -B - Change Attribute game.pick2 to random(4,45)
    ---those two change attributes will change depending on which Scene you're on, we'll come to that later)
    Change Attibute PickChoice to random(1,2)
    Rule: When PickChoice = 1
    Change Attribute FinalPick = pick1
    otherwise
    Change Attribute FinalPick = pick2

    Rule: When FinalPick = 1
    Change Scene Go to Scene: Scene 1

    Rule: When FinalPick = 2
    Change Scene Go to Scene: Scene 2

    Rule: When FinalPick = 3
    Change Scene Go to Scene: Scene 3
    -------ETC; all the way to Scene 45

    • Now place this button on each of your scenes, making sure to make all of them instances by unlocking them.

    • Next is the amendments to each of the Rules in each button, depending on which scene you're in. The following applies to scenes 3 thru to 43:
    Change where I've marked A, random so that the max. is the scene before the scene you're on.
    Change where I've marked B, random so that the min. is the scene after the scene you're on.

    In the Change Scene Go to Scene Rules, just change the one "entry" which will show the scene you're on, to what it should be.

    • For scene 1 you obviously don't need A, just B, i.e random(2,45); and scene 45, you don't need B, just A: random(1,44) but still put the result into PickChoice to save you some work.

    • For Scene 2, make pick = 1, i.e no random required, and for scene 44, make pick2 = 45, again no random required.

    Hope that all makes sense; good luck with it!

    :-)

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • CaptFinnCaptFinn Member Posts: 1,828
    So your way reducess the amount of rules that have to be upload from scene to scene. which will shorten loading times?
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    It's safe to say you need a ton and a half of Rules to affect loading time of each scene; it's the assets - the graphics and sounds - which affect scene loading times.

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • CaptFinnCaptFinn Member Posts: 1,828
    Ive got a question here onthe forum in regards to just that. It deals with background images. same per scene or different per scene. Can you take a look at it? its called background.png question
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    I'm off out now (really) so I haven't got the time; I'll take a look when I get back but I'm sure you're question will be answered by someone else by the time I get back.

    P.S A "thanks" would have been nice. ;-)

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

Sign In or Register to comment.