Skip to content

Instantly share code, notes, and snippets.

@rawo2010
Last active March 7, 2018 02:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rawo2010/db1bca58519019f80502dc63843d46de to your computer and use it in GitHub Desktop.
Save rawo2010/db1bca58519019f80502dc63843d46de to your computer and use it in GitHub Desktop.
ContactPointsExample of use Raw
//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