/// <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); }
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); }
/// <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); }
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; } }
/// <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); }
/// <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); }
/// <summary> /// Jumps this instance. /// </summary> public void Jump() { KinematicCharacter.Jump(); }
/// <summary> /// Moves the specified movement. /// </summary> /// <param name="movement">The movement.</param> public void Move(Vector3 movement) { KinematicCharacter.SetWalkDirection(movement); }
/// <summary> /// Teleports the specified target position. /// </summary> /// <param name="targetPosition">The target position.</param> public void Teleport(Vector3 targetPosition) { KinematicCharacter.Warp(targetPosition); }
/// <summary> /// Jumps this instance. /// </summary> public void Jump() { var zeroV = Vector3.Zero; //passing zero will jump on Up Axis KinematicCharacter?.Jump(ref zeroV); }
/// <summary> /// Jumps this instance. /// </summary> public void Jump(Vector3 jumpDirection) { KinematicCharacter?.Jump(ref jumpDirection); }
// Use this for initialization void Start() { //gets the target DynamicCharacter's properties this.targetCharacter = this.targetGameObject.GetComponent <CharacterKinematicMovementController>().character; }
//early initialization void Awake() { this.character = new KinematicCharacter(gameObject); this.movementTextText = this.movementText.GetComponent <Text>(); }