Created
May 15, 2016 17:46
-
-
Save FCkaisei/783a15dd01ee323c1ca568ed36d7e3ee to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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