Exemplo n.º 1
0
    protected override void FixedUpdate()
    {
        if (isDead)
        {
            return;
        }

        if (target)
        {
            Vector3 targetPos = target.position;
            if (Vector3.Distance(transform.position, targetPos) < stunRange)
            {
                PlayerMovement.Instance.Stun();
            }
            else
            {
                Vector3 dir = new Vector3();
                dir   = targetPos - transform.position;
                dir.y = transform.position.y;
                dir   = Vector3.ClampMagnitude(dir, 1);

                Animator.SetFloat("Horizontal", dir.x);
                Animator.SetFloat("Vertical", dir.z);
                RB.velocity = Vector3.zero;
                RB.MovePosition(transform.position + dir * movementSpeed * Time.deltaTime);
            }
        }
    }
Exemplo n.º 2
0
        public virtual void BehaviorUpdate()
        {
            GetTarget();
            Vector2 next = LocationUtilities.NextLocation(Combatant.transform.position, Target.transform.position, Combatant.speed);

            RB.MovePosition(next);
        }
Exemplo n.º 3
0
 /// <summary>
 /// Moves the battery in the given direction
 /// This is for when the battery is on a conveyor belt
 /// </summary>
 /// <param name="dir"></param>
 /// <param name="speed"></param>
 public void MoveOnConveyorBelt(Vector3 dir, float speed)
 {
     // Stop moving since it is no longer fired
     RB.velocity = Vector3.zero;
     dir.y       = 0;
     RB.MovePosition(RB.position + (speed * dir) * Time.deltaTime);
 }
Exemplo n.º 4
0
 private void ApplyNonUnitySolver()
 {
     // example index 0, 1 are input and 2..7 are transform outputs
     // there is no example fmu for this
     RB.MovePosition(new Vector3((float)fmu.GetReal(FMUData.modelVariables[2].name),
                                 (float)fmu.GetReal(FMUData.modelVariables[3].name),
                                 (float)fmu.GetReal(FMUData.modelVariables[4].name)));
     RB.MoveRotation(Quaternion.Euler(new Vector3((float)fmu.GetReal(FMUData.modelVariables[5].name),
                                                  (float)fmu.GetReal(FMUData.modelVariables[6].name),
                                                  (float)fmu.GetReal(FMUData.modelVariables[7].name))));
 }
    private void PEDMove()
    {
        if (controller.MovementSpeed != 0f)
        {
            RB.MovePosition(RB.position + transform.forward * (controller.MovementSpeed * Time.fixedDeltaTime));
        }
        else
        {
            RB.velocity = Vector3.zero;
        }

        var previousVelocity = controller.CurrentVelocity;

        controller.CurrentVelocity     = (RB.position - LastRBPosition) / Time.fixedDeltaTime;
        controller.CurrentAcceleration = controller.CurrentVelocity - previousVelocity;
        LastRBPosition = RB.position;
    }
Exemplo n.º 6
0
 public void ForceReset(Vector3 pos, Quaternion rot)
 {
     RB.MovePosition(pos);
     RB.MoveRotation(rot);
     RB.velocity        = Vector3.zero;
     RB.angularVelocity = Vector3.zero;
     CurrentGear        = 1;
     CurrentRPM         = 0f;
     CurrentSpeed       = 0f;
     currentTorque      = 0f;
     AccellInput        = 0f;
     SteerInput         = 0f;
     foreach (var axle in axles)
     {
         axle.wheel.brakeTorque = Mathf.Infinity;
         axle.wheel.motorTorque = 0f;
     }
 }
Exemplo n.º 7
0
    public bool ForceReset(Vector3 pos, Quaternion rot)
    {
        RB.MovePosition(pos);
        RB.MoveRotation(rot);
        RB.velocity        = Vector3.zero;
        RB.angularVelocity = Vector3.zero;
        CurrentGear        = 1;
        CurrentRPM         = 0f;
        AccellInput        = 0f;
        SteerInput         = 0f;

        foreach (var axle in Axles)
        {
            axle.Left.brakeTorque  = Mathf.Infinity;
            axle.Right.brakeTorque = Mathf.Infinity;
            axle.Left.motorTorque  = 0f;
            axle.Right.motorTorque = 0f;
        }
        return(true);
    }
Exemplo n.º 8
0
    /// <summary>
    /// Moves into the given robot's battery slot and powers it back on
    /// </summary>
    /// <param name="robot"></param>
    /// <returns></returns>
    IEnumerator AttachToRobotRoutine(PlayerRobot robot)
    {
        m_isAttaching = true;

        // Disable collisions until it is fired again
        m_rigidbody.detectCollisions = false;

        Vector3 destination = robot.BatterySlot.position;

        while (Vector3.Distance(m_rigidbody.position, destination) > .001f)
        {
            Vector3 towards = Vector3.MoveTowards(RB.position, destination, m_speed * Time.deltaTime);
            RB.MovePosition(towards);
            yield return(new WaitForEndOfFrame());
        }

        RB.position = destination;
        Attached    = true;
        PlayerController.Instance.SwitchRobot(robot);

        m_isAttaching = false;
    }
Exemplo n.º 9
0
 /// <summary>
 /// Pushes the player in the given direction, ignoring y
 /// </summary>
 /// <param name="dir"></param>
 public void MoveInDirection(Vector3 dir, float speed)
 {
     dir.y = 0;
     RB.MovePosition(RB.position + (speed * dir) * Time.deltaTime);
 }
Exemplo n.º 10
0
    /// <summary>
    /// Moves the robot in the direction of the player's input
    /// </summary>
    void Move()
    {
        Vector3 targetPosition = RB.position + (m_inputVector.normalized * m_movementSpeed) * Time.deltaTime;

        RB.MovePosition(targetPosition);
    }