void CheckInputsRotation(ComponentPlayerController cpc, Entity e) { float newRightRotation = 0.0f; if (Keyboard.GetState().IsKeyDown(Key.Left)) { newRightRotation += cpc.RotationSpeed; } if (Keyboard.GetState().IsKeyDown(Key.Right)) { newRightRotation -= cpc.RotationSpeed; } float changeInX = Mouse.GetState().X - PreviousMousePosition.X; newRightRotation -= changeInX * cpc.RotationSpeed; if (newRightRotation > cpc.RotationSpeed) { newRightRotation = cpc.RotationSpeed; } else if (newRightRotation < -cpc.RotationSpeed) { newRightRotation = -cpc.RotationSpeed; } e.Transform.Rotation *= Quaternion.FromEulerAngles(new Vector3(0, newRightRotation * TimeManager.dt, 0)); }
void CheckInputsVelocity(ComponentPlayerController cpc) { float speed = 0.0f; Vector3 forward = Vector3.Zero; if (Keyboard.GetState().IsKeyDown(Key.Up)) { speed += cpc.MovementSpeed; forward = cpc.Transform.Forward; } if (Keyboard.GetState().IsKeyDown(Key.Down)) { speed = cpc.MovementSpeed; if (forward != Vector3.Zero) { forward = Vector3.Zero; } else { forward = -cpc.Transform.Forward; } } cpc.RigidBody.Velocity = forward * speed * TimeManager.dt; }