- Home /
Making side-scrolling movement?
Hey Im trying to make a 2d side-scrolling hack n' slash game. But i have some trouble with the movement script, so was wondering if have anyone could help me? The script im using is this
var speed : float = 6.0;
var jumpSpeed : float = 8.0;
var gravity : float = 20.0;
private var moveDirection : Vector3 = Vector3.zero;
function Update () {
var controller : CharacterController = GetComponent(CharacterController);
if(controller.isGrounded)
{
//We are grounded so recalculate
//move direction directly from axes
moveDirection = Vector3(0,0,Input.GetAxis("Horizontal"));
//moveDirection = transform.TransformDirection(moveDirection);
//controller.transform.LookAt();
moveDirection *=speed;
if(moveDirection.sqrMagnitude > 0.01)
transform.rotation = Quaternion.Slerp (Transform.Rotation, Quaternion.LookRotation(moveDirection),1);
if(Input.GetButton("Jump"))
{
moveDirection.y = jumpSpeed;
}
}
//Apply gravity
moveDirection.y -= gravity *Time.deltaTime;
//Move the controller
controller.Move(moveDirection * Time.deltaTime);
}
But i keep getting the error:
"MissingMethodException: Method not found: 'UnityEngine.Quaternion.slerp'. Boo.Lang.Runtime.DynamicDispatching.MethodDispatcherFactory.ProduceExtensionDispatcher () Boo.Lang.Runtime.DynamicDispatching.MethodDispatcherFactory.Create () Boo.Lang.Runtime.RuntimeServices.DoCreateMethodDispatcher (System.Object target, System.Type targetType, System.String name, System.Object[] args) Boo.Lang.Runtime.RuntimeServices.CreateMethodDispatcher (System.Object target, System.String name, System.Object[] args) Boo.Lang.Runtime.RuntimeServices+c_AnonStorey12.<>m_6 () Boo.Lang.Runtime.DynamicDispatching.DispatcherCache.Get (Boo.Lang.Runtime.DynamicDispatching.DispatcherKey key, Boo.Lang.Runtime.DynamicDispatching.DispatcherFactory factory) Boo.Lang.Runtime.RuntimeServices.GetDispatcher (System.Object target, System.String cacheKeyName, System.Type[] cacheKeyTypes, Boo.Lang.Runtime.DynamicDispatching.DispatcherFactory factory) Boo.Lang.Runtime.RuntimeServices.GetDispatcher (System.Object target, System.Object[] args, System.String cacheKeyName, Boo.Lang.Runtime.DynamicDispatching.DispatcherFactory factory) Boo.Lang.Runtime.RuntimeServices.Invoke (System.Object target, System.String name, System.Object[] args) UnityScript.Lang.UnityRuntimeServices.Invoke (System.Object target, System.String name, System.Object[] args, System.Type scriptBaseType) platform_controller.Update () (at Assets/platform_controller.js:20)"