Can you help me to find a script for collision a sphere to an object and change the scenes in the same time ?
using UnityEngine;
using System.Collections;
using UnityEngine.SceneManagement;
public class Load : MonoBehaviour {
// Use this for initialization
public void PickUp() {
SceneManager.LoadScene ("_Scene");
}
// Update is called once per frame
void Player() {
SceneManager.LoadScene ("_Scene2");
}
}
I made this script but i need collision to add...Can you help me ?
Comment
Best Answer
Answer by ClearRoseOfWar · Jan 07, 2016 at 01:41 AM
so what I think you want is this -> when the player collides with the 'pickup' item, it would load a scene?
Just give the pickup item the tag of "PickUp" or something, and give it a box collider. Make sure to check the is Trigger checkbox. In the case of sphere, just use a sphere collider.
then attach this script to the player:
public class ExampleClass : MonoBehaviour {
void OnTriggerEnter(Collider other) {
if(other.tag == "PickUp"){
SceneManager.LoadScene ("_Scene2");
}
}
}
I'm sure with a bit of help from google, you could have found this with a bit of tinkering...