Add rotation

This commit is contained in:
James Hodgson
2022-04-11 19:14:57 +01:00
parent 917119d319
commit 340171cd06
2 changed files with 12 additions and 26 deletions

View File

@@ -22,8 +22,8 @@ public class FishController : MonoBehaviour
void Update()
{
float moveX = Input.GetAxisRaw("Horizontal");
float moveZ = Input.GetAxisRaw("Vertical");
float moveX = 0 - Input.GetAxisRaw("Vertical");
float moveZ = Input.GetAxisRaw("Horizontal");
float moveGravity = gravity * Time.deltaTime;
if (controller.isGrounded && velocity.y < 0)
@@ -37,9 +37,11 @@ public class FishController : MonoBehaviour
}
velocity.x = moveX * speed;
velocity.z = moveZ * speed;
// velocity.z = moveZ * speed;
velocity.y += moveGravity;
transform.Rotate(0, moveZ, 0);
Vector3 moveVelocity = velocity * Time.deltaTime;
if (moveVelocity.y < 0 && Math.Abs(moveVelocity.y) < controller.minMoveDistance)
@@ -47,6 +49,6 @@ public class FishController : MonoBehaviour
moveVelocity.y = (gravity * 0.1f) * Time.deltaTime;
}
controller.Move(moveVelocity);
controller.Move(transform.rotation * moveVelocity);
}
}