Hi Im trying when capsule player jump rotating.
but it couldnt work… when player jump gravity direction is also rotating and looks funny…
i wanna player rotate 360 degree when jump. and gravity must be same direction positive y direction.
here is my code.
void FixedUpdate () {
System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
//time = sw.ElapsedMilliseconds;
//timetext.text = time.ToString();
//transform.position = new Vector3(transform.position.x, transform.position.y, 0.3f);
PlayerMove();
PlayerJump();
}
void PlayerJump()
{
if (Input.GetKey(KeyCode.Space) && isGround)
{
rd.AddForce(Vector3.up * jumpPower);
isJump = true;
}
if (!isGround)
{
Quaternion deltarotation = Quaternion.Euler(player_velocity * Time.deltaTime);
rd.MoveRotation(rd.rotation * deltarotation);
isJump = false;
}
}
void PlayerMove()
{
float moveFoward = Input.GetAxis("Horizontal") * Time.deltaTime;
moveFoward *= speed;
transform.Translate(new Vector3(moveFoward, 0, 0));
}
thanks