Hi,
From what I have found online, I think this is the gist for finding whether one game object collides with another. What I am trying to acheive, is that if a cube (Player) comes into contact with a plane (Plane). Here is what I have done so far:
1) In the Unity Game Engine, created a game object named Player, which is a cube.
2) Made another game object in the UGE named Plane, which is a plane
3) Made a PreFab, named PlayerPositionPreFab, for the game object named Plane, and did a drag and drop so that Plane has the PreFab, PlayerPositionPreFab.
4) I checked the isTrigger box for the Plane.
--The Player's position (cube) will always be changing. I want to write Debug.Log("asdf") to the screen when the Player is over the mesh of the Plane.
5) I wrote the following C# Script (with some generous help), to try and do this:
public class Plane : MonoBehaviour // Plane Script checks for PlayerCollision Against itself
{
// GameObject PreFabs for the player
public GameObject PlayerPositionPreFab;
//private double x = 0;
// Use this for initialization
void Start ()
{
}
// Update is called once per frame
void Update ()
{
}
void OnTriggerEnter(Collider other)
{
if (other.gameObject.name == "Player")
{
Debug.Log("Yay!");
}
}
void OnTriggerStay(Collider other)
{
// if some condition
Debug.Log("Staying on the Plane");
}
void OnTriggerExit(Collider other)
{
// if some condition
Debug.Log("Exiting on the Plane");
}
}