Advertisement
gaidzinski07

Untitled

Aug 1st, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.54 KB | None | 0 0
  1. public class GolemMovement : MonoBehaviour {
  2.     public float moveForce = 1F;
  3.     Vector3 v = new Vector3(0f, 0f, 0f);
  4.     void Update () {
  5.         float h = Input.GetAxis("Horizontal");
  6.         if (transform.position.x >= 10 && h*moveForce<0)
  7.         {
  8.             v = new Vector3(0f, 0f, 0f);
  9.         }else if(transform.position.x <= -10 && h * moveForce > 0)
  10.         {
  11.             v = new Vector3(0f, 0f, 0f);
  12.         }else
  13.         {
  14.             v = new Vector3(h * moveForce, 0f, 0f);
  15.         }
  16.         transform.Translate(v);
  17.     }
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement