Hi
Is there a way to get notified when a rigidbody changes it’s velocity, for example when it collides with a physic material object?!
kind regards
Jürgen:face_with_spiral_eyes:
Hi
Is there a way to get notified when a rigidbody changes it’s velocity, for example when it collides with a physic material object?!
kind regards
Jürgen:face_with_spiral_eyes:
You don’t need to detect the change in velocity for that.
Rigidbody.OnCollisionEnter
Example taken from unity reference.
using UnityEngine;
using System.Collections;
public class example : MonoBehaviour {
void OnCollisionEnter(Collision collision) {
foreach (ContactPoint contact in collision.contacts) {
Debug.DrawRay(contact.point, contact.normal, Color.white);
}
if (collision.relativeVelocity.magnitude > 2)
audio.Play();
}
}
Reference found here. Unity - Scripting API: Rigidbody.OnCollisionEnter(Collision)
Thanks, didn’t think about this way