- Home /
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.
or
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
Indeed. 4 programmers and you are all working on a tutorial?
Describe what does happen, and what doesn't happen.
Thank you all for your help. I like learning but this is completely out of my realm. I dont know the rules so how would I know what commands work with things like gravity vs kinematic. I dont code. I dont do physics. Animator my job is to break the rules of reality lol. Wheres a good place for someone who is level 0 in skill to learn this stuff. Right now this isnt learning its monkey see monkey do and god forbid I click something on accident.
Answer by gjf · Jan 19, 2015 at 09:13 AM
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.
Answer by Baste · Jan 19, 2015 at 09:41 AM
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.
Yes it was set to kinematic and gravity. The ball moves now, all though I must say extremely slow. All the informatin listed by everyone is good to know thank you very much.
Your answer
Follow this Question
Related Questions
Unity jumping sound, help. 1 Answer
How to upload a game to the internet 1 Answer
How do you CORRECTLY call methods from another C# file 1 Answer
how do I save a script when access is denied? 0 Answers
Unity 5 can't start up 0 Answers