Esempio n. 1
0
    public void doPunch()
    {
        Vector3 destination = transform.position + (transform.right * speed);
        Vector3 dir         = (destination - transform.position).normalized;

        transform.position += dir * speed * Time.deltaTime;

        if (Vector3.Distance(player.transform.position, transform.position) >= distance)
        {
            stateOfPunch = punchState.backwards;
        }
    }
Esempio n. 2
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(punchKey))
        {
            if (stateOfPunch == punchState.ready)
            {
                punchStart   = transform.localPosition;
                stateOfPunch = punchState.forward;
            }
        }


        if (stateOfPunch == punchState.forward)
        {
            doPunch();
        }
        if (stateOfPunch == punchState.backwards)
        {
            resetPunch();
        }
    }
Esempio n. 3
0
 public void resetPunch()
 {
     transform.localPosition = punchStart;
     stateOfPunch            = punchState.ready;
 }
Esempio n. 4
0
 private void Start()
 {
     stateOfPunch = punchState.ready;
 }