Beispiel #1
0
        public override void Update(float dt)
        {
            PlayerController.Update(dt);

            if (PlayerController.Changed())
            {
                var rotation = PlayerCamera.GetRotation();
                rotation += new Float3(PlayerController.RotationDelta) * dt;
                float rotationY = RyneMath.Clamp(rotation.Y, -89.0f, 89.0f);
                PlayerCamera.SetRotation(new Float3(rotation.X, rotationY, 0));

                // We only want the player entity to rotate horizontally
                Transform.Rotation = new Rotator(new Float3(rotation.X, 0, 0)).ToQuaternion();
            }

            PlayerCamera.SetPosition(Transform.GetLocation());
            PlayerCamera.Update(dt);
        }
Beispiel #2
0
        public virtual void UpdateEntities(float dt)
        {
            if (!Changed())
            {
                return;
            }

            foreach (var entity in ControlledEntities)
            {
                // Update entity transform
                ref var transform = ref entity.Transform;

                if (RotationDelta.Length() > Constants.Epsilon)
                {
                    var rotation = transform.Rotation.ToRotator().ToFloat4();
                    rotation += RotationDelta * dt;
                    if (ClampVerticalRotation)
                    {
                        rotation.Y = RyneMath.Clamp(rotation.Y, -89.0f, 89.0f);
                    }

                    transform.Rotation = new Rotator(rotation).ToQuaternion();
                }

                if (MovementRawDelta.Length() > Constants.Epsilon)
                {
                    if (AddMovementAsForce)
                    {
                        ref var physics = ref entity.Physics;
                        physics.Acceleration += MovementNormalizedDelta * dt;
                        physics.Velocity     += MovementDirectDelta * dt;
                    }
                    else
                    {
                        transform.Position += MovementRawDelta * dt;
                    }
                }