I have a Water Layer and I want to play a splash prefab when an sphere touches it. This code works in some way, it plays the splash when the sphere touches the ground.
function OnCollisionEnter(collision : Collision)
{
if (collision.relativeVelocity.magnitude > 1){
Instantiate(prefab, transform.position, Quaternion.identity);
}
}
This code doesn’t work:
function OnTriggerEnter(other : Collider) {
Instantiate(prefab, transform.position, Quaternion.identity);
}
The water have isTrigger on, is a rigidbody with kinematic on and the object is a rigidbody. But the code does nothing, the sphere goes underwater.
Please help me with a solution.