Exemplo n.º 1
0
 protected virtual void Awake()
 {
     _jumpTime         = _jumpDuration;
     _oriantation      = Oriantation.left;
     _anim             = GetComponent <Animator>();
     _characterRigBody = GetComponent <Rigidbody>();
     _opponent         = GameObject.FindGameObjectWithTag("Opponent");
 }
Exemplo n.º 2
0
    private void LookAtOpponent(float rotSpeed)
    {
        //getting the direction that should be looking at which is in this case the opponent
        Vector3 direction = _opponent.transform.position - transform.position;
        //Then, get the dot product of the direction with the direction the opponent is looking
        float dot = Vector3.Dot(direction, _opponent.transform.forward);

        //The result will be -1 if the target is directly behind, +1 if directly ahead and zero if it is side-on to the NPC in any direction (including above, below, etc).
        // the dot product is being used here to see the direction 1 if they are same direction, -1 if the exact opposite and zero if they are
        //perpendicular
        if (dot <= 0)
        {
            transform.rotation = Quaternion.Lerp(transform.rotation, Quaternion.Euler(0, 90, 0), rotSpeed);
            _oriantation       = Oriantation.right;
        }
        else
        {
            transform.rotation = Quaternion.Lerp(transform.rotation, Quaternion.Euler(0, -90, 0), rotSpeed);
            _oriantation       = Oriantation.left;
        }
    }
    void InstantiateBlockSizeForBackWall(int s, int xCumBlock, int argxOffset, int argyOffset, Oriantation argOr)
    {
        Vector3 here = new Vector3(xCumBlock + argxOffset, 0, argyOffset);


        Quaternion QRotation = new Quaternion();

        switch (argOr)
        {
        case Oriantation.Right:
            QRotation = Quaternion.Euler(OrientRight);
            break;

        case Oriantation.Down:
            QRotation = Quaternion.Euler(OrientDown);
            break;

        case Oriantation.Left:
            QRotation = Quaternion.Euler(OrientLeft);
            break;

        case Oriantation.Up:
            QRotation = Quaternion.Euler(Orientup);
            break;
        }


        if (s == 1)
        {
            Instantiate(C1, here, QRotation);
        }
        else
        if (s == 2)
        {
            Instantiate(C2, here, QRotation);
        }
        else
        if (s == 3)
        {
            Instantiate(C3, here, QRotation);
        }
    }