Add rotation
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user