- Home /
The question is answered, right answer was accepted
Can't get roll a ball to roll
After taking a decade or so off from programming I am trying to restart using Unity... new to it and C# (used C a lot). When I hit play the ball does not move at all. I think I followed everything in the tutorial exactly, and have read all the questions like mine where the answer ends up being a typo. I am not seeing my mistake, here is the code:
using UnityEngine; using System.Collections;
public class PlayerController : MonoBehaviour { public float speed;
void FixedUdate()
{
float moveHorizontal = Input.GetAxis ("Horizontal");
float moveVeritcal = Input.GetAxis ("Vertical");
Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVeritcal);
Debug.Log ("moved " + moveHorizontal + " " + moveVeritcal);
rigidbody.AddForce(movement * speed * Time.deltaTime);
}
}
FWIW I am REALLY impressed something like this is available for free!!!
Is that debug log printing? Check your console window. It could be showing inappropriate values (in which case something about your input is wrong), you could see another error (in which case, fix that), or you could see nothing at all (in which case, maybe make sure the script is attached to something in the scene).
What is the value of speed
? If you multiply force by zero, you won't push anything.
Answer by tw1st3d · May 28, 2014 at 09:50 PM
void FixedUdate()
should be
void FixedUpdate()
Yep, it was the misspelling of FixUpdate :)figured it would be something like that. Thanks much for the quick answer. To answer the log printing question, it was not showing anything (and it's not showing anything was the final straw before I went online to ask). The log output works (naturally) now that the function name is correct. I guess there is no equivalent of linker/loader errors in this environment....
Thanks much for the quick help!