Last active
March 7, 2018 02:05
-
-
Save rawo2010/db1bca58519019f80502dc63843d46de to your computer and use it in GitHub Desktop.
ContactPointsExample of use Raw
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
//Update内でPositionに加算するなりしてください。 | |
Vector3 vecocity = new Vector3(0,0,0); | |
//衝突したとき の イベント | |
private void OnCollisionEnter(Collision collision) | |
{ | |
Vector3 normal = Vector3.zero ; | |
//法線ベクトルを取得 | |
foreach(ContactPoint contact in collision.contacts){ | |
if(contact.thisCollider.name == name){ | |
normal = contact.normal ; | |
} | |
} | |
//反射ベクトルを求めます | |
vecocity = vel + (2 * Vector3.Dot(-vel, normal) * normal) ; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment