Real Code for this Topic (Solution - Real Stuff)

Using 3d for this project is an overkill so I started as 2d but after that I saw 3d was a choice to not teach some stuff (I really do not like this course the quality is not close other courses). So Use a sprite inside player object but be careful, in cartesian coordinates 0,0 is facing right so sprite have to face right too. then use this code(or you can set it according to facing top)

BTW FEED THIS FUNCTION WITH TOUCH COORDINATES AS WORLD COORD. SO SHIP IS ALWAYS FACE AT THE DIRECTION JET BLOWS LIKE REAL ONE

void RotateToFaceToTouch(Vector2 rotateTo)
    {
        //Calculate Rotation
        float y = rotateTo.y - transform.position.y;
        float x = rotateTo.x - transform.position.x;
        float degreeToTurn = Mathf.Atan2(y, x) *Mathf.Rad2Deg;
        Debug.Log(degreeToTurn);
        float actualRotation = transform.rotation.z;
        transform.rotation = Quaternion.Euler(0,0,degreeToTurn + actualRotation);

    }

I agree that 3D is overkill for this project, however, I also understand the choice to keep it in 3D. Since this is a course focused on mobile applications, they didn’t want to stray too far from the previous projects, both of which were in 3D. Learning two different workflows that have nothing to do with Mobile would introduce more difficulties than what is already a more intermediate course. For those who would like to learn how to apply these in 2D, I would highly suggest the Complete 2D Online Course.

I am like you though, as I have been going off script on this course to challenge myself. =D Keep it up!

Privacy & Terms