[Solved] Issues applying impulse on mouse click
Posted: Mon Jan 18, 2016 5:32 pm
Hi, I'm working on implementing a game using Bullet SDK. Right now I'm trying to apply impulse to my game objects when theyre clicked on.
When I run the following code in my "ApplyForce" funciton, which is called when an object is clicked, nothing happens
But if I use the same idea in my "Update" function, which is called every step, it works. By same code I mean applying a set impulse to the center of my object.
What could be causing this?
When I run the following code in my "ApplyForce" funciton, which is called when an object is clicked, nothing happens
Code: Select all
void PhysicsComponent::ApplyForce(glm::vec3& hitPoint, glm::vec3& direction, float amount)
{
if (!m_body)
return;
m_body->activate(true);
btVector3 force = btVector3(0, 1, 0) * amount;
m_body->applyImpulse(force, centerOfMass);
}
What could be causing this?