Created
November 25, 2018 14:57
-
-
Save JPBotelho/23e8050d349dd5e6634645543876427f to your computer and use it in GitHub Desktop.
Ship Bounce
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void OnTriggerEnter(Collider other) | |
{ | |
Debug.Log("Collided with " + other.transform.name); | |
Vector3 rbVelocity = Actor.RigidbodyComp.velocity; | |
Vector3 direction = transform.position - GetComponent<Collider>().transform.position; | |
direction.Normalize(); | |
Actor.RigidbodyComp.velocity = Vector3.zero; | |
Actor.RigidbodyComp.AddForce(-rbVelocity.normalized * force, ForceMode.Impulse); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment