Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // GETS THE BOUNDA WHERE MONSTER CAN MOVE
- Vector3 ScreenSpace = new Vector3(0.95f,0.1f,1.0f);
- Vector3 ConvertedVector3 = Camera.main.ViewportToWorldPoint(ScreenSpace);
- // GET X AXIS MIDLE POINT
- float MidScreen = ConvertedVector3.x /2;
- // GET CURRENT POSITION OF THE MONSTER
- Vector3 CurrentPositionVector = transform.position;
- Vector3 CurrentConvertedPosition = Camera.main.ViewportToWorldPoint(CurrentPosition);
- // POSITION OF THE MONSTER IN SCREEN SPACE
- float CurrentPosition = CurrentConvertedPosition.x;
- // MOVE THE MONSTER
- if(CurrentPosition < MidScreen) {
- // MOVE LEFT
- } else {
- // MOVE RIGHT
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement