I've made a character capsule standing upright that I move around by setting velocities and applying impulses. I set the angular factor on this capsule to zero, so that it won't tip over.
The capsule slides around on the ground, and I can hit other objects and jump on them, run it over by a vehicle. Things are starting to work nicely!
Now I would like to know if the capsule is touching something. For example, I'd only apply a jump impulse if the capsule is standing on something to begin with. And walking should not be possible while in free fall..
What would be the best way to check for this?
Also, I am uncertain if I'm doing the movement code in the right place. Now, the main loop in the program looks something like this:
Code: Select all
while(1) {
int max_iter = 10;
physics_world_->stepSimulation(dt_, max_iter);
// Update objects
for(list<WbWorldObject*>::iterator i = worldobject_list_.begin();
i != worldobject_list_.end(); ++i)
{
WbWorldObject* av = *i;
av->timeStep(dt_, this);
}
}
Maybe a better way would be to implement a character class similar to the raycar vehicle, and put the character control inside the updateVehicle() function that is called from within stepSimualation?
Best regards,
Ola