Advertisement
Guest User

Code

a guest
Jun 22nd, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. // GETS THE BOUNDA WHERE MONSTER CAN MOVE
  2. Vector3 ScreenSpace = new Vector3(0.95f,0.1f,1.0f);
  3. Vector3 ConvertedVector3 = Camera.main.ViewportToWorldPoint(ScreenSpace);
  4.  
  5. // GET X AXIS MIDLE POINT
  6. float MidScreen = ConvertedVector3.x /2;
  7.  
  8. // GET CURRENT POSITION OF THE MONSTER
  9. Vector3 CurrentPositionVector = transform.position;
  10. Vector3 CurrentConvertedPosition = Camera.main.ViewportToWorldPoint(CurrentPosition);
  11.  
  12. // POSITION OF THE MONSTER IN SCREEN SPACE
  13. float CurrentPosition = CurrentConvertedPosition.x;
  14.  
  15. // MOVE THE MONSTER
  16. if(CurrentPosition < MidScreen) {
  17. // MOVE LEFT
  18. } else {
  19. // MOVE RIGHT
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement