Miziziziz

Left and Right Movement

Oct 2nd, 2014
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.27 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class PlayerMovement : MonoBehaviour {
  5.  
  6.  
  7.     public float speed = 5f;
  8.  
  9.     void Update()
  10.     {
  11.         float x = Input.GetAxis ("Horizontal");
  12.         rigidbody2D.velocity = new Vector2 (x * speed, rigidbody2D.velocity.y);
  13.     }
  14. }
Add Comment
Please, Sign In to add comment