- Home /
Roll-a-ball tutorial: help with movement
Hey I am following the Roll-a-ball tutorial. I did everything till the 3rd chapter"moving the ball". I wrote the same script as shown in the video . But i am not able to move the ball as shown in the video . Heres the script.
well i think you should add something more, like the script..
It's possible that the code you've typed in has a mistake in it. Please can you copy and paste your code, so we can compare it to that in the video?
I have same problem here , how was it solved,tvm? Enrico/ italy
Answer by Kons · Dec 17, 2013 at 08:43 PM
The problem is your function is called in the wrong way
void FixedUpdate is different from Fixedupdate in C#
void FixedUpdate() {
}
should do the trick.
Also i don't know why Unity didn't implement those functions as virtual instead of having the people look on the doc to know which are available.. :)
Answer by emalb · Dec 19, 2013 at 10:52 AM
The problem is the lower case u in Fixedupdate.
If you change that to upper case it will then be FixedUpdate.
Function names are case sensitive, so if you get the case wrong it won't be called.
(@Kons pointed this out in the above answer, but I don't think you caught the critical point.)
Also, when you paste script here it's more useful if you copy and paste the actual text, rather than a screen shot of it. That way people who are answering your question can copy the script into the answer and make edits more easily. :)
using UnityEngine; using System.Collections;
public class Playercontroller : $$anonymous$$onoBehaviour { void FixedUpdate () { float moveHorizontal = Input.GetAxis ("Horizontal"); float moveVertical = Input.GetAxis ("Vertical");
Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical);
rigidbody.AddForce (movement*10.0f);
}
}
I Appreciate you guys answering my stupid questions but this is still not working and this is getting really irritating . Do we have to control the ball with the arrow keys or what .$$anonymous$$aybe the script is correct and the problem is something else , how do i know ? I have made the whole project again 2 times now and did exactly what was shown in the video .
using UnityEngine; using System.Collections;
public class Playercontroller : $$anonymous$$onoBehaviour { void FixedUpdate () { float moveHorizontal = Input.GetAxis ("Horizontal"); float moveVertical = Input.GetAxis ("Vertical");
Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical);
rigidbody.AddForce (movement*10.0f);
}
}
HEY I GOT IT ! .IT WOR$$anonymous$$S FINE NOW .I TOO$$anonymous$$ HELP FRO$$anonymous$$ A FRIEND BUT THAN$$anonymous$$ YOU GUYS FOR YOUR TI$$anonymous$$$$anonymous$$
Hi, How can I roll the ball using aceelerometer of BlackBerry 10
Answer by alex narvas · Oct 11, 2014 at 03:42 AM
I solved the problem by uninstalling the new Unity and then installing the previous versions from the archive, like unity 3, unity 4, unity 4.5 and then 4.6.
Answer by romero400 · Jan 16, 2015 at 07:15 PM
This is a very common problem.
You must create a plane. Make a sphere and set it's transform to x = 0 y = 0.5 z = 0. Add a rigidbody to the sphere. Create a C# script called PlayerConroller or something like that.
Now, here's what you put in it:
When you go back to the editor, set the 'public float speed' to whatever you want! I recommend 500. I hope this was helpful.
Your answer
Follow this Question
Related Questions
physics rolling error( included sample and simple demo) 0 Answers
Roll-A-Ball Problem 2 Answers
roll-a-boll tutorial-rotator error 1 Answer