View difference between Paste ID: T7n69ncd and znmrJAGe
SHOW: | | - or go back to the newest paste.
1
using UnityEngine;
2
using System.Collections;
3
4
public class UserControl : MonoBehaviour {
5
	
6
	Transform look;
7
	
8
	Character character;
9
	
10
	// Use this for initialization
11
	void Start () {
12
		look = GetComponentInChildren<MouseLookPivot>().transform;
13
		character = GetComponent<Character>();
14
	}
15
	
16
	// Update is called once per frame
17-
	void Update () {
17+
	void FixedUpdate () {
18
	
19
		bool walk = Input.GetKey(KeyCode.LeftShift);
20
		float v = Input.GetAxis("Vertical");
21
		float h = Input.GetAxis("Horizontal");
22
23-
		Vector3 move = v * look.forward + h * look.right;		
23+
		Vector3 move = v * look.forward + h * look.right;	
24-
		Vector3 localMove = transform.InverseTransformDirection(move);		
24+
25-
		float turn = Mathf.Atan2( localMove.x, localMove.z );
25+
26
		
27-
		float forward = localMove.magnitude;
27+
		character.Move( move, walk, lookPos);
28
	}
29
}