Problem when applying linear velocity to a sphere

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
zeeba
Posts: 4
Joined: Mon Mar 01, 2010 9:42 pm

Problem when applying linear velocity to a sphere

Post by zeeba »

Ok, this is kind of a noob question :P
I have constructed a small room-like environment (floor and 4 walls), all made from box entities with no mass... so I drop a sphere in the middle of the room and I apply a random linear velocity to it, everything works fine, the sphere bounces a bit, slides and eventually stops, then I want to apply another random linear velocity (as if I was shaking the environment a little bit), but nothing happens, the sphere stays still... am I doing something wrong? am I supposed to use another method other than applyLinearVelocity?

Thanks!
Gerard
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Problem when applying linear velocity to a sphere

Post by Norbo »

What you're seeing is probably the rest system in action. Once an entity settles down, it will 'turn off.' The applyLinearImpulse method doesn't reactivate an entity. You can set an entity's isActive property to true to force it awake.

Usually, the simplest thing to do is just use the linearVelocity property instead. It will handle the activation automatically. So instead of e.applyLinearImpulse(velocityYouWant * mass), you can just write e.linearVelocity += velocityYouWant.
zeeba
Posts: 4
Joined: Mon Mar 01, 2010 9:42 pm

Re: Problem when applying linear velocity to a sphere

Post by zeeba »

Ah, that sounds good, I'll try it as soon as I get home this afternoon :)

Thx!
Post Reply