Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- public class Controller : MonoBehaviour {
- public int speed = 1;
- void Update ()
- {
- float mouseX = Input.GetAxisRaw("Mouse X");
- float vel = mouseX * speed;
- if (mouseX != 0)
- {
- gameObject.GetComponent<Rigidbody>().isKinematic = false;
- if (mouseX < 0)
- {
- gameObject.GetComponent<Rigidbody>().velocity = new Vector3(vel, 0, 0);
- }
- else
- {
- gameObject.GetComponent<Rigidbody>().velocity = new Vector3(vel, 0, 0);
- }
- } else
- {
- gameObject.GetComponent<Rigidbody>().isKinematic = true;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment