hi, im making an fps game and i have a button that makes you go to the next level when clicked, the only problem is i don’t want the mouse on the screen so i want the button to be clicked when i shoot it.
Thanks.
hi, im making an fps game and i have a button that makes you go to the next level when clicked, the only problem is i don’t want the mouse on the screen so i want the button to be clicked when i shoot it.
Thanks.
It depends on how you are shooting - with Raycast or with a projectile. If you shoot a projectile, you can use OnCollisionEnter at the button script, like this:
function OnCollisionEnter(){ Application.LoadLevel("LevelName"); }
Anything that hits the button will load the new level.
If you are shooting with Raycast, on the other hand, you must identify the button with a specific tag or name, and place this code in the shooting script:
// your shooting code must be something like this: if (Physics.Raycast(ray, hit)){ // check if the button named "NextLevelButton" was hit if (hit.transform.name == "NextLevelButton"){ Application.LoadLevel("LevelName"); } ...