I need a Javascript… When a player touch the cube, then scene 1 will load…
I have this found on Internet:
Application.LoadLevel ("HighScore");
But what’s next? I’m pretty bad in Javascript.
Thanks
I need a Javascript… When a player touch the cube, then scene 1 will load…
I have this found on Internet:
Application.LoadLevel ("HighScore");
But what’s next? I’m pretty bad in Javascript.
Thanks
I’m more of a c# guy, so I’m not going to try to write the script but the logic would be somehting like this:
1/ Add a boxcollider to your cube
2/ Write a script with this logic in it and add it to your camera for example.
var cubeCollider : Collider;
if(Input.GetButtonDown(0)) // you should change this if you're using multi-touch
{
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); // also to be changed if on multitouch
RaycastHit hit;
if (Physics.Raycast(ray, out hit, 100)) // cast a ray and check if something was hit
{
if(hit.collider == cubeCollider) // if something was hit, check if collider is that of the cube
{
Application.LoadLevel(1); // Loading scene 1
}
}
}
3/ drag your cube in the cubeCollider variable exposed in the inspector
You can do this :
Application.LoadLevel ("TheNameOfYourScene");
but I think you will need more than that to do what you want after this small step.