Example #1
0
        /// <summary>
        /// Sets the character velocity.
        /// Velocity will be applied every frame unless modified or canceled passing Vector3.Zero.
        /// </summary>
        /// <remarks>The engine internally will multiply velocity with the simulation fixed time step.</remarks>
        /// <param name="velocity">The velocity vector, typically direction * speed.</param>
        public void SetVelocity(Vector3 velocity)
        {
            if (KinematicCharacter == null)
            {
                throw new InvalidOperationException("Attempted to call a Physics function that is avaliable only when the Entity has been already added to the Scene.");
            }

            KinematicCharacter.SetWalkDirection(velocity * Simulation.FixedTimeStep);
        }
Example #2
0
        public void Move(Vector3 movement)
        {
            if (KinematicCharacter == null)
            {
                throw new InvalidOperationException("Attempted to call a Physics function that is avaliable only when the Entity has been already added to the Scene.");
            }

            KinematicCharacter.SetWalkDirection(movement);
        }
Example #3
0
 /// <summary>
 /// Jumps this instance.
 /// </summary>
 public void Jump(Vector3 jumpDirection)
 {
     if (KinematicCharacter == null)
     {
         throw new InvalidOperationException("Attempted to call a Physics function that is avaliable only when the Entity has been already added to the Scene.");
     }
     BulletSharp.Math.Vector3 bV3 = jumpDirection;
     KinematicCharacter.Jump(ref bV3);
 }
Example #4
0
 private void UpdateMovingGameObject(KinematicCharacter movingCharacter)
 {
     if (movingCharacter.Movement != null)
     {
         movingCharacter.Update();
         movingCharacter.StaticData.ApplyWorldLimit(X_WORLD_SIZE, Z_WORLD_SIZE);
         movingCharacter.GameObject.transform.position = movingCharacter.StaticData.position;
     }
 }
Example #5
0
        /// <summary>
        /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
        /// </summary>
        public override void Dispose()
        {
            if (KinematicCharacter != null)
            {
                KinematicCharacter.Dispose();
                KinematicCharacter = null;
            }

            base.Dispose();
        }
        /// <summary>
        /// Jumps this instance.
        /// </summary>
        public void Jump()
        {
            if (KinematicCharacter == null)
            {
                throw new InvalidOperationException("Attempted to call a Physics function that is avaliable only when the Entity has been already added to the Scene.");
            }

            var zeroV = Vector3.Zero; //passing zero will jump on Up Axis

            KinematicCharacter.Jump(ref zeroV);
        }
Example #7
0
        /// <summary>
        /// Teleports the specified target position.
        /// </summary>
        /// <param name="targetPosition">The target position.</param>
        public void Teleport(Vector3 targetPosition)
        {
            if (KinematicCharacter == null)
            {
                return;
            }

            //we assume that the user wants to teleport in world/entity space
            var entityPos = Entity.Transform.Position;
            var physPos   = PhysicsWorldTransform.TranslationVector;
            var diff      = physPos - entityPos;

            KinematicCharacter.Warp(targetPosition + diff);
        }
        /// <summary>
        /// Teleports the specified target position.
        /// </summary>
        /// <param name="targetPosition">The target position.</param>
        public void Teleport(Vector3 targetPosition)
        {
            if (KinematicCharacter == null)
            {
                throw new InvalidOperationException("Attempted to call a Physics function that is avaliable only when the Entity has been already added to the Scene.");
            }

            //we assume that the user wants to teleport in world/entity space
            var entityPos = Entity.Transform.Position;
            var physPos   = PhysicsWorldTransform.TranslationVector;
            var diff      = physPos - entityPos;

            KinematicCharacter.Warp(targetPosition + diff);
        }
Example #9
0
 /// <summary>
 /// Jumps this instance.
 /// </summary>
 public void Jump()
 {
     KinematicCharacter.Jump();
 }
Example #10
0
 /// <summary>
 /// Moves the specified movement.
 /// </summary>
 /// <param name="movement">The movement.</param>
 public void Move(Vector3 movement)
 {
     KinematicCharacter.SetWalkDirection(movement);
 }
Example #11
0
 /// <summary>
 /// Teleports the specified target position.
 /// </summary>
 /// <param name="targetPosition">The target position.</param>
 public void Teleport(Vector3 targetPosition)
 {
     KinematicCharacter.Warp(targetPosition);
 }
Example #12
0
        /// <summary>
        /// Jumps this instance.
        /// </summary>
        public void Jump()
        {
            var zeroV = Vector3.Zero; //passing zero will jump on Up Axis

            KinematicCharacter?.Jump(ref zeroV);
        }
Example #13
0
 /// <summary>
 /// Jumps this instance.
 /// </summary>
 public void Jump(Vector3 jumpDirection)
 {
     KinematicCharacter?.Jump(ref jumpDirection);
 }
Example #14
0
 // Use this for initialization
 void Start()
 {
     //gets the target DynamicCharacter's properties
     this.targetCharacter = this.targetGameObject.GetComponent <CharacterKinematicMovementController>().character;
 }
Example #15
0
 //early initialization
 void Awake()
 {
     this.character        = new KinematicCharacter(gameObject);
     this.movementTextText = this.movementText.GetComponent <Text>();
 }