Beispiel #1
0
    // FixedUpdate is called once per frame after physics calls
    void FixedUpdate()
    {
        MovementInput();
        Ray        moveRay = new Ray(transform.position, direction);
        RaycastHit colDetect;
        //Checks if we are falling; sets grounded to true if we're not falling
        //if (Mathf.Abs(r.velocity.y) <= 0.005f) grounded = true; else { grounded = false; }

        Ray        fallRay = new Ray(transform.position, Vector3.down);
        RaycastHit fallCheck;

        grounded = Physics.Raycast(fallRay, out fallCheck, 0.2f) && fallCheck.collider.tag != null;

        if (!PauseStepping)
        {
            if (grounded)
            {
                AnimationTriggerManager.OnLand();
                //When the step timer is up
                if (stepTimer <= 0f)
                {
                    // Reset stepTimer length
                    stepTimer = stepDelay;
                    // Sets the new point in which we want to move to...
                    newLocation = transform.position + direction;
                    if (Physics.Raycast(moveRay, out colDetect, 1.0f))
                    {
                        if (colDetect.collider != null)
                        {
                            newLocation.Set(newLocation.x, newLocation.y + 1, newLocation.z);
                        }
                    }
                    AnimationTriggerManager.OnStep();
                }
            }
            else
            {
                AnimationTriggerManager.OnFall();
            }
        }
        if (!grounded)
        {
            newLocation.Set(transform.position.x, GetTopSurface().y, transform.position.z);
        }
        //Debug.DrawLine (transform.position, newLocation);
        //Debug.DrawLine(GetTopSurface(), transform.position, Color.red);
        // Begin stepTimer countdown
        if (stepTimer >= 0f)
        {
            stepTimer -= Time.deltaTime;
        }
        UnifyPosition();
    }
Beispiel #2
0
    private void MovementInput()
    {
        if (Mathf.Abs(Input.GetAxisRaw("Horizontal")) >= 0.1f)
        {
            direction = new Vector3((int)Input.GetAxisRaw("Horizontal"), 0, 0);

            AnimationTriggerManager.OnDirectionChange(direction);
        }
        if (Mathf.Abs(Input.GetAxisRaw("Vertical")) >= 0.1f)
        {
            direction = new Vector3(0, 0, (int)Input.GetAxisRaw("Vertical"));

            AnimationTriggerManager.OnDirectionChange(direction);
        }
    }
Beispiel #3
0
 void Awake()
 {
     m_animator     = GetComponent <Animator>();
     m_triggerNames = new List <string>();
     AnimatorControllerParameter[] parameters = m_animator.parameters;
     for (int i = 0; i < parameters.Length; i++)
     {
         if (parameters[i].type == AnimatorControllerParameterType.Trigger)
         {
             m_triggerNames.Add(parameters[i].name);
         }
     }
     m_triggerMgr = new AnimationTriggerManager(m_animator, "isIdle");
     m_triggerMgr.Add("isMove", "isIdle");
     m_triggerMgr.Add("isAttack", "isIdle");
     m_triggerMgr.Add("isKick", "isAttack");
     m_triggerMgr.Add("isFrontKickR", "isKick");
     m_triggerMgr.Add("isFrontKickL", "isKick");
     m_triggerMgr.Add("isPunch", "isAttack");
     m_triggerMgr.Add("isPunchL", "isPunch");
     m_triggerMgr.Add("isPunchR", "isPunch");
     m_triggerMgr.Add("isPunchMoveL", "isPunch");
     m_triggerMgr.Add("isPunchMoveR", "isPunch");
 }