relativeVelocity
The relative linear velocity of the two colliding objects (Read Only).
Read time 1 minuteLast updated 10 days ago
Definition
- Type: Property
- Namespace: UnityEngine
- Assembly: UnityEngine.PhysicsModule
public Vector3 relativeVelocity { get; }
Examples
// Play a sound when we hit an object with a big velocityusing UnityEngine;using System.Collections;public class ExampleClass : MonoBehaviour{ AudioSource audioSource; void Start() { audioSource = GetComponent<AudioSource>(); } void OnCollisionEnter(Collision collision) { if (collision.relativeVelocity.magnitude > 2) audioSource.Play(); }}