x


Sphere get stuck in floor and fails to jump?

I have a rigid body with a sphere collider sitting on a floor. It has this in fixed update:

if (Input.GetKeyDown(KeyCode.Space))
{
    rigidbody.velocity = Vector3.up * 4;
}

If I try to jump as soon as the sphere reaches the floor, it will occasionally fail to jump (remains stationary). Since I am setting velocity directly instead of incrementing it, I know it isn't being cancelled out by any existing negative velocity. Also, I don't have any logic to ensure that the player is on the ground before letting them jump, so that's not the problem either.

Any thoughts on how to fix this? Thanks.

more ▼

asked Jan 18 '12 at 02:55 AM

jeff2365 gravatar image

jeff2365
16 1 1 2

Doubt this is the problem but usually Input gets checked in the normal update function..

Jan 18 '12 at 03:11 AM merry_christmas

Nope, that doesn't fix it, but thanks, I'll keep that in mind.

Jan 18 '12 at 03:55 AM jeff2365

So if the sphere is in the air it will always move upwards but if it is touching the ground it sometimes fails to move?

Jan 18 '12 at 03:57 AM merry_christmas

Under Detonator,explosion effects. will cause object jump, dunno if it does help to you as you can check it up

Jan 18 '12 at 04:03 AM wenhua

Hey wenhua, answered your question http://answers.unity3d.com/questions/206791/how-to-make-a-sphereball-blinking.html I'm curious to find out whether it works xD

Jan 18 '12 at 04:08 AM merry_christmas
(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

For anyone else with this problem make sure to check for input in the regular Update() function and not in the fixed update function :)

more ▼

answered Jan 20 '12 at 05:55 PM

merry_christmas gravatar image

merry_christmas
3.3k 5 11 17

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x2497
x1874
x1367
x804
x335

asked: Jan 18 '12 at 02:55 AM

Seen: 844 times

Last Updated: Jan 20 '12 at 05:55 PM