Hello,
In the game i am doing now, the player is moving at high speed with jetpack。
I use a spherecast surrounding the player body to get any collision.
so whenever my player speed is over 50 m per second
i check for collision, now the part i am stuck on:
i want to kill the player when he hit a surface normal angle that is >25 degres to the velocity angle
So in this example my player is moving horizontaly from left to right
hit normal2 is the ground, moving at high speed on the ground in this angle should not make it die
hit normal1 is a wall he hit the wall at high speed :the playerdirection and hit.normal1 angle is 90 degres player should die
I am using this code:
sphereRadius = 1.6F;
refPos = this.transform.position+newVector3(0,1.2F,0);
if (Physics.SphereCast (refPos, sphereRadius, newVector3 (0.001F, 0.001F, 0.001F), outhit, mask))
{
Vector3HitSurface = hit.normal;
Vector3playerMoveDirection = ufpsController.Velocity;
floatangle = Vector3.Angle (HitSurface,playerMoveDirection);; //theanglebetweenplayermovingdirectionandthesurfacewehit
Debug.Log ("angle: "+angle);
Debug.Log ("velocity: "+playerMoveDirection);
//KillPlayer ();
}
edit: i fixed the rigidbody, it use ufps physics, the rigidbody didnt returned the correct velocity before.
however the angle returned are sometime strange: 0,1 179 degres how should i understand this? its same?