Пример #1
0
    public void SetToRotation(MDIRECTION dir)
    {
        direction          = dir;
        transform.rotation = Quaternion.AngleAxis(0, Vector3.up);               //default rotation

        //to assign an initial direction to the character, use this  instead of transform->Rotation
        switch (dir)
        {
        case MDIRECTION.FORWARD:
            transform.rotation *= Quaternion.AngleAxis(0, Vector3.up);
            break;

        case MDIRECTION.LEFT:
            transform.rotation *= Quaternion.AngleAxis(-90f, Vector3.up);
            break;

        case MDIRECTION.BACKWARD:
            transform.rotation *= Quaternion.AngleAxis(180f, Vector3.up);
            break;

        case MDIRECTION.RIGHT:
            transform.rotation *= Quaternion.AngleAxis(90f, Vector3.up);
            break;
        }
    }
Пример #2
0
    public void TurnRight()
    {
        playerAudio.PlayAudioFor("TurnRight()");

        canMove = false;
        moving  = true;

        transform.rotation *= Quaternion.AngleAxis(90f, Vector3.up);    //this rotation is purely for visual representation

        switch (direction)
        {
        case MDIRECTION.FORWARD:
            direction = MDIRECTION.RIGHT;
            break;

        case MDIRECTION.LEFT:
            direction = MDIRECTION.FORWARD;
            break;

        case MDIRECTION.BACKWARD:
            direction = MDIRECTION.LEFT;
            break;

        case MDIRECTION.RIGHT:
            direction = MDIRECTION.BACKWARD;
            break;
        }
    }
Пример #3
0
    public void TurnLeft()
    {
        playerAudio.PlayAudioFor("TurnLeft()");

        canMove = false;
        moving  = true;

        transform.rotation *= Quaternion.AngleAxis(-90f, Vector3.up);           //this rotates the model

        //changes the enum direction for the upcoming instructions
        switch (direction)
        {
        case MDIRECTION.FORWARD:
            direction = MDIRECTION.LEFT;
            break;

        case MDIRECTION.LEFT:
            direction = MDIRECTION.BACKWARD;
            break;

        case MDIRECTION.BACKWARD:
            direction = MDIRECTION.RIGHT;
            break;

        case MDIRECTION.RIGHT:
            direction = MDIRECTION.FORWARD;
            break;
        }
    }
Пример #4
0
 void SetInitialRotation(MDIRECTION dir)
 {
     initialDirection = dir;
 }