Change scenes with JavaScript


#1

hi!
How I could make a change of scenes in JavaScript?
time ago we could use the number of the scene, its ID
the ID of Scenes has vanished!
go to “name” scene?
where is the ID now?
Help, please
Thanks


#2

Hi @arbues,

You can change the scenes now via index like this:

  • To enter the first scene, write Space.goToScene(0);
  • To enter the third scene, write Space.goToScene(2);
  • etc.

You can also change to the next or previous scenes via:

  • Space.goToPreviousScene()
  • Space.goToNextScene()

We’re also looking into allowing you to enter a scene via scene name in the future, too.


#3

thanks, it works!!!
thanks a lot!!!
one more question
do you know how it works the option “on hover” with oculus go?
mouse over? do you what option is?
thanks


#4

Hi @arbues!

If you want to create an onHover event by script, you can use the following code:

let myItem = Scene.getItem('Cuboid') as GameItem;

myItem.onHover(isHovering => {
    if (isHovering) {
        //Code when item is hovered
    }
    else {
        //Code when item is not hovered anymore
    }
})

The onHover logic will only happen on Oculus Go when you point with the controller towards it.

Check out the space below on how onHover behavior is made in JavaScript or CoBlocks! Press the remix button to copy the space :slight_smile: