Moves the character with speed.
private void Move() { Vector3 inputMovement = new Vector3(_inputMove.x, 0, _inputMove.y) * this._movementSpeed; Vector3 movement = transform.forward * inputMovement.z + transform.right * inputMovement.x; charController.SimpleMove(movement); }
static public int SimpleMove(IntPtr l) { try { #if DEBUG var method = System.Reflection.MethodBase.GetCurrentMethod(); string methodName = GetMethodName(method); #if UNITY_5_5_OR_NEWER UnityEngine.Profiling.Profiler.BeginSample(methodName); #else Profiler.BeginSample(methodName); #endif #endif UnityEngine.CharacterController self = (UnityEngine.CharacterController)checkSelf(l); UnityEngine.Vector3 a1; checkType(l, 2, out a1); var ret = self.SimpleMove(a1); pushValue(l, true); pushValue(l, ret); return(2); } catch (Exception e) { return(error(l, e)); } #if DEBUG finally { #if UNITY_5_5_OR_NEWER UnityEngine.Profiling.Profiler.EndSample(); #else Profiler.EndSample(); #endif } #endif }
static public int SimpleMove(IntPtr l) { try { UnityEngine.CharacterController self = (UnityEngine.CharacterController)checkSelf(l); UnityEngine.Vector3 a1; checkType(l, 2, out a1); var ret = self.SimpleMove(a1); pushValue(l, ret); return(1); } catch (Exception e) { return(error(l, e)); } }
static public int SimpleMove(IntPtr l) { try{ UnityEngine.CharacterController self = (UnityEngine.CharacterController)checkSelf(l); UnityEngine.Vector3 a1; checkType(l, 2, out a1); System.Boolean ret = self.SimpleMove(a1); pushValue(l, ret); return(1); } catch (Exception e) { LuaDLL.luaL_error(l, e.ToString()); return(0); } }
static int SimpleMove(IntPtr L) { try { ToLua.CheckArgsCount(L, 2); UnityEngine.CharacterController obj = (UnityEngine.CharacterController)ToLua.CheckObject(L, 1, typeof(UnityEngine.CharacterController)); UnityEngine.Vector3 arg0 = ToLua.ToVector3(L, 2); bool o = obj.SimpleMove(arg0); LuaDLL.lua_pushboolean(L, o); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
static int SimpleMove(IntPtr L) { #if UNITY_EDITOR ToluaProfiler.AddCallRecord("UnityEngine.CharacterController.SimpleMove"); #endif try { ToLua.CheckArgsCount(L, 2); UnityEngine.CharacterController obj = (UnityEngine.CharacterController)ToLua.CheckObject(L, 1, typeof(UnityEngine.CharacterController)); UnityEngine.Vector3 arg0 = ToLua.ToVector3(L, 2); bool o = obj.SimpleMove(arg0); LuaDLL.lua_pushboolean(L, o); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
// Update is called once per frame void Update() { // Rotate around y-axis float newRotation = Input.GetAxis("Horizontal") * rotationSpeed; transform.Rotate(0, newRotation * Time.deltaTime, 0); // Calculate speed float newSpeed = Input.GetAxis("Vertical") * speed; if (Input.GetKey("left shift")) { newSpeed *= 1.5f; } controller = GetComponent<CharacterController>(); controller.SimpleMove(transform.TransformDirection(Vector3.forward) * newSpeed); // Update the speed in the Animation script SendMessage("SetCurrentSpeed", newSpeed, SendMessageOptions.DontRequireReceiver); SendMessage("SetCurrentLean", Input.GetAxis("Horizontal"), SendMessageOptions.DontRequireReceiver); }
//Factoring out in case of expansion/adding footsteps or whatever void Move(Vector3 forward, CharacterController controller, float currentSpeed) { controller.SimpleMove(forward * currentSpeed); }