Exemple #1
0
 public void ConnectTo(Transform inputConnectionTransform)
 {
     connectionTarget = inputConnectionTransform;
     if (connectionTarget.GetComponent <CharacterMovementController>())
     {
         CharacterMovementInfo c = connectionTarget.GetComponent <CharacterMovementController>().characterInfo;
         parts.head.localScale  = parts.head.localScale * ((float)c.movementSpeed / 700f);
         parts.torso.localScale = parts.torso.localScale * ((float)c.weight / 2f);
     }
 }
Exemple #2
0
 public override void ProcessMovementFromInput(CharacterMovementInfo movementData)
 {
 }
Exemple #3
0
 public void SetAvatarShape(CharacterMovementInfo inputCharacterMovementInfo)
 {
 }
Exemple #4
0
        public override void ProcessMovementFromInput(CharacterMovementInfo movementData)
        {
            Vector3 totalMovement = Vector3.Zero;
            Vector3 movementDir;
            float   movementSpeed = 1.0f;

            // Grab the current camera's ID
            var camMsg = ObjectPool.Aquire <MsgGetRenderEntity>();

            this.game.SendInterfaceMessage(camMsg, InterfaceType.Camera);

            // Get the current camera's rotation
            var msgGetRot = ObjectPool.Aquire <MsgGetRotation>();

            msgGetRot.UniqueTarget = camMsg.EntityID;
            this.game.SendMessage(msgGetRot);

            if (movementData.forward > 0.0f)
            {
                movementDir    = msgGetRot.Rotation.Forward;
                totalMovement += movementDir;
            }
            else if (movementData.forward < 0.0f)
            {
                movementDir    = msgGetRot.Rotation.Forward;
                totalMovement -= movementDir;
            }

            if (movementData.right < 0.0f)
            {
                movementDir    = msgGetRot.Rotation.Left;
                totalMovement += movementDir;
            }
            else if (movementData.right > 0.0f)
            {
                movementDir    = msgGetRot.Rotation.Right;
                totalMovement += movementDir;
            }

            if (totalMovement == Vector3.Zero)
            {
                character.HorizontalMotionConstraint.MovementDirection = Vector2.Zero;
            }
            else
            {
                totalMovement.Y = 0.0f;
                totalMovement.Normalize();

                Matrix rot = msgGetRot.Rotation;
                rot.Forward = totalMovement;
                rot.Up      = Vector3.Up;
                rot.Right   = Vector3.Cross(rot.Forward, rot.Up);

                var msgSetRot = ObjectPool.Aquire <MsgSetRotation>();
                msgSetRot.Rotation     = rot;
                msgSetRot.UniqueTarget = this.ownerEntityID;
                this.game.SendMessage(msgSetRot);

                character.HorizontalMotionConstraint.MovementDirection = new Vector2(totalMovement.X, totalMovement.Z);

                var msgGetVel = ObjectPool.Aquire <MsgGetLinearVelocity>();
                msgGetVel.UniqueTarget = this.ownerEntityID;
                this.game.SendMessage(msgGetVel);

                if (msgGetVel.LinearVelocity.LengthSquared() <= 400.0f)
                {
                    var msgSetVel = ObjectPool.Aquire <MsgAddLinearForce>();
                    msgSetVel.LinearVelocity = totalMovement * movementSpeed;
                    msgSetVel.UniqueTarget   = this.ownerEntityID;
                    this.game.SendMessage(msgSetVel);
                }
            }

            character.StanceManager.DesiredStance = movementData.crouching ? Stance.Crouching : Stance.Standing;

            // Jumping
            if (movementData.wantsJump)
            {
                character.Jump();
            }
        }
Exemple #5
0
 public abstract void ProcessMovementFromInput(CharacterMovementInfo movementData);