- Home /
Ball not rolling fast on first movement
Hi, I recently completed the Roll-a-ball tutorial, and have been trying to fix some issues with the movement of the ball. On the first time I try and move the ball either vertically or horizontally, it does not roll to its maximum speed. To get it to its maximum speed, I have to roll it on the other axis as well. For example, if I started rolling the ball downwards, I would have to roll it sideways to get it to start reaching its maximum speed. Also, rolling the ball diagonally makes it work again.
Another issue is diagonal movement- I tried to normalize the vector so that the ball doesn't move faster diagonally, but it rolls at a vector of 0.7,0,0.7 for example, while when it rolls down its vector is 1.0,0,0. Is this correct behaviour or should I multiply the vector by the 'magic number'? This is my code for the movement of the ball:
void FixedUpdate()
{
Vector3 direction = new Vector3 (Input.GetAxis ("Horizontal"), 0, Input.GetAxis ("Vertical"));
if (direction.magnitude > 1)
{
direction.Normalize ();
}
rigidbody.AddForce (direction*speed*Time.deltaTime);
print (direction);
}
Your answer
Follow this Question
Related Questions
Increasing the speed of an object when the scale is decreased and vice versa 0 Answers
NavAgent Speed & Rigidbody Velocity 1 Answer
Normalizing vector doesn't give a constant direction. 2 Answers
Player moves diagonally even when not telling him to 0 Answers
Diagonal movement speed difference with normalized vector 0 Answers