Roll a ball tutorial Problem Please Help

Roll A Ball Moving the Player. It doesnt work. I have no error codes, no warnings, nothing shows up as wrong and yet I hit play and nothing I mean nothing happens. I am an animator working with 4 programmers who cannot be bothered. 20 hours wasted on this and I do not know what on earth is wrong. Sending my script as an attachment so someone who actually knows C# and isn’t guessing like me can tell me its messed up or where I messed up. Yes the script is on the ball/Player.



using UnityEngine; using System.Collections;

public class godsavethePlayer : MonoBehaviour 
    void FixedUpdate ()
        float moveHorizontal = Input.GetAxis ("Horizontal"); 
        float moveVertical = Input.GetAxis ("Vertical");
        Vector3 movement = new Vector3 (moveHorizontal,0.0f,moveVertical);
        rigidbody.AddForce (movement * Time.deltaTime);

Had to add extra spaces to get it to show up as more than 4 lines

2 pieces of advice:

  1. Add a Debug.Log in FixedUpdate to check that it’s getting there

  2. dump those programmers - if they can’t be bothered, find some that can.

So, there’s some possible reasons I can think of:

1: you might not have set up the input axes in the Input Manager. Horizontal and Vertical might be mapped to some other keys than what you’re expecting.

2: The rigidbody you’re trying to do this with is kinematic. In that case, it doesn’t react to force.

3: You’re doing this is FixedUpdate, while the Input function resets every Update frame. The axes should still have values in Fixed, but there might be issues.

if you add Debug.Log(movement) in before the AddForce, you’ll see if you’re getting any readings at all, which will narrow it down.

Oh, and before anyone goes “you should use Time.fixedDeltaTime instead!”, Time.deltaTime is Time.fixedDeltaTime in FixedUpdate, so don’t even bother.