private Collision ball = null;
// Use this for initialization
void Start()
{
}
// Update is called once per frame
void Update()
{
OnCollisionEnter(ball);
}
void OnCollisionEnter(Collision check)
{
if(check.gameObject.tag == "Player")
Debug.Log("HIT HIT HIT");
//Application.LoadLevel("FirstDragTest");
}
It seems so simple but it’s doing my head in. Can’t find an example anywhere. New to Unity scripting so I could really use some help on this one. I want to send a message when the my ball object hits the floor.
There are so many posts on this topic already. Please search before asking. And if stuck, ask a precise question : what doesn’t work? Where is the error? What does the documentation say? Are there any examples in the documentation?
Gave the Cube a RigidBody ( this would be your ball )
Set the Cube tag to Player
Added this c# script to the Plane ( named Floor )
using UnityEngine;
using System.Collections;
public class Floor : MonoBehaviour {
void OnCollisionEnter(Collision check){
if(check.gameObject.tag == "Player")
Debug.Log("HIT HIT HIT");
}
}