duck

Unity 3D Mecanim User Control Script

Feb 27th, 2013
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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 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;  
  24.        
  25.         Vector3 lookPos = look.position + look.forward*10;
  26.        
  27.         character.Move( move, walk, lookPos);
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment