Ambiera ForumDiscussions, Help and Support. |
|
|
|||||
|
Hi, I'm very new to CC and would like to ask, if I have say 10 different scenes made and a menu. If I click "Go!" on the menu for example, it then randomly goes to any of those 10 scenes made? Sorry if this is stupid question. |
||||
|
No, not at all. You can specify what scene you want it to change to very easily. It's called "switch to scene" Or do you want it to specifically go to a random one? |
||||
|
Thanks for the reply, and I found the switch to scene but I'm looking for it to be random, just to switch up the game in lieu of any form of procedurally generated levels. |
||||
|
if you name your scenes "Scene1","Scene2","Scene3" ect... and then when click enter this javascript... var value = (Math.random() * (10 - 1)) + 1; that might work. |
||||
|
Excellent, thanks Tim, I'm at work tonight but I'll be sure to give it a try tomorrow. Thanks for your help |
||||
|
Hi @astronomical Here's non-scripted and easy method for you. But as you have just used tim's method so I am just telling you about it. When clicked Do something: Set random value Every 1 millisecond do something: Check if <variable name> is 1 do something: Change scene to <first scene> Check if <variable name> is 2 do something: Change scene to <second scene> and so on... |
||||
|
First of all, thanks for your input. Tim, I give that a try and at first I had a box with a "if clicked on action" then "execute javascript". Just added it without the scenes and it thrown up errors saying it couldn't find random scenes between 1 and 10. Great! so I made 10 scenes with different colour backgrounds to named "Scene1" up to 10, and now it does nothing haha. Nothing flags up in console and it just seems to not execute the JS. Behroz-khan, thanks for your reply also, am incredibly new to this whole thing, I'm more of a music and design guy, so I've not played with variables. I have zero knowledge of this stuff. :( Oh and I'm not sure if this makes any difference, but I'm using the Steam version of CC6 Pro |
||||
|
what?!? how can this be???!! the code... it was so perfect in my mind.... ... ... LOOK AWAY FROM ME!!!!! i cannot stand the shame of failure!!! you MUST send me more information... a detailed description... a screenshot.... heck even the .ccb file itself so i can fix it! I MUST MAKE THINGS RIGHT to restore my honor again!!! |
||||
|
@tim12345 There is no error in your piece of code....it should work exactly as you had thought...you are a good programmer... @astronomical the problem is that you have different scenes with different backgrounds color... and it is a very old bug in coppercube when the scene is changed the background color remains same or change to default color... so i would like to suggest you to try the code by @tim12345 with different scenes... without having different background color... i know you wanted to test out the code.. so instead of background color .. you can add diffrent scenenode.. for example use a sphere in scene 1.. and a soldier in scene 2.. and so on... for the method proposed by @behroz khan... it will consume a lot of time... because you will have to add 10 times "if a variable has a value" and then 10x time another action to execute switch scene.. and if you want to do the same process in all the 10 scene then it will take 100x time to add those actions... so i will recommend to use the method proposed by @tim12345 |
||||
|
For the three scenes "Cube," "Sphere," and "Plane" this code will randomly switch to one of them. var myScenes = ["Cube", "Sphere", "Plane"] |
||||
|
Oh yeah @just-in-case i didn't thought of it but my method would only be easy when using a little amount of scenes like 5 or so. |
|