Skip to content

Instantly share code, notes, and snippets.

@FCkaisei
Created May 15, 2016 17:46
Show Gist options
  • Save FCkaisei/783a15dd01ee323c1ca568ed36d7e3ee to your computer and use it in GitHub Desktop.
Save FCkaisei/783a15dd01ee323c1ca568ed36d7e3ee to your computer and use it in GitHub Desktop.
using UnityEngine;
using System.Collections;
public class PlayerControll : MonoBehaviour {
float mouseX;
Rigidbody rigidbody;
void Start(){
rigidbody = GetComponent<Rigidbody> ();
}
void FixedUpdate (){
float axisZ = Input.GetAxis("Vertical");
float axisX = Input.GetAxis ("Horizontal");
mouseX += Input.GetAxis("Mouse X");
rigidbody.velocity = Vector3.zero;
transform.localRotation = Quaternion.Euler(0, mouseX*100*Time.deltaTime, 0);
rigidbody.AddRelativeForce (new Vector3(100*axisX,0,100*axisZ));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment