Ambiera ForumDiscussions, Help and Support. |
|
|
|||||
|
Hello! I just find the "Switch to Scene"-command, but it doesn't restart the scene like the "Restart a scene" Behavior does (i'm already in that scene, so switch doesnt do anything) How can i do this? :-) Thanks a lot! |
||||
|
Use the "Restart scene" action before using "Switch to scene". Like this: - Restart scene: target scene - Switch to scene: target scene Just tried it with 2 simple scenes, switching back and forth between them. Seemed to work (Camera + objects did go back to initial positions). |
||||
|
If you want to do a scene-restart in pure CopperCube javascript, you may need to use a workaround. The action "Restart a scene" doesn't seem to have a js-function equivalent. Two workarounds. Workaround 1: You could transfer your current script into a scripted action or behavior (.js). In the script-file header-block comments add: <property name="my_action_list" type="action"/> Later invoke the action list in your code: ccbInvokeAction(this.my_action_list, currentNode); Or: ccbInvokeAction(this.my_action_list); The "my_action_list" would contain: - "Restart a scene": target_scene - "Switch to another scene": target_scene Workaround 2: You could signal the scene-transition to an object using a CopperCube variable. - Create a "plane" object (or whatever object you like) - Attributes: uncheck "Collision", uncheck "OccludesLight", "Scale" = 0,0,0 - Attributes: "Visible" needs to be checked - seems the behavior doesn't work if the object is invisible - Add a behavior "Every few seconds do something" - IntervalMS = 250 - Action "If a Variable has a value do something" -> Is LevelSwitch equal to Value 1 ? - Action list (If condition is true): - "Set or Change a Variable" -> set LevelSwitch to Value 0 - "Restart a scene": target_scene - "Switch to another scene": target_scene To trigger the scene transition, you can now "send a signal" to the object by setting the LevelSwitch-variable to 1. ccbSetCopperCubeVariable("LevelSwitch", 1); Further notes: I have no idea if it is possible to interface the built-in actions via javascript when they are not directly exposed as callable functions. The engine appears to contain internal references to "RestartScene" and "SwitchToScene". |
||||
|
Thanks guys! :-) i went with the second aproach and had a "If variable has a value" checking for a variable to be changed! |
||||
|
coppercube has a function to do that ccbSwitchToScene("scene_name");edit: nevermind... i tried and looks like it doesnt reset the scene |
||||
|
|