Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class GolemMovement : MonoBehaviour {
- public float moveForce = 1F;
- Vector3 v = new Vector3(0f, 0f, 0f);
- void Update () {
- float h = Input.GetAxis("Horizontal");
- if (transform.position.x >= 10 && h*moveForce<0)
- {
- v = new Vector3(0f, 0f, 0f);
- }else if(transform.position.x <= -10 && h * moveForce > 0)
- {
- v = new Vector3(0f, 0f, 0f);
- }else
- {
- v = new Vector3(h * moveForce, 0f, 0f);
- }
- transform.Translate(v);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement