setLinearVelocity - object not moving

Post Reply
_hiya_
Posts: 4
Joined: Thu Aug 20, 2015 10:10 pm

setLinearVelocity - object not moving

Post by _hiya_ »

Hi,
I am having trouble moving an object by using the "setLinearVelocity" method
the object just spins (very fastly) in air but doesnt move.
What I am trying to do is to shoot the object like in the bullet "DemoApplication" example
My code is almost identical to the example code.

what's wrong, any ideas?
_hiya_
Posts: 4
Joined: Thu Aug 20, 2015 10:10 pm

Re: setLinearVelocity - object not moving

Post by _hiya_ »

if my question wasn't clear, I am trying to do the same thing like shootBox example

DemoApplication::shootBox(const btVector3& destination)

but when I use it in my code the box just spins and doesnt move forward.

I tried to change gravity, mass etc. but it just doesn't move.
I am creating the rigidbody, btDynamicsWorld etc like in the sample code.
anthrax11
Posts: 72
Joined: Wed Feb 24, 2010 9:49 pm

Re: setLinearVelocity - object not moving

Post by anthrax11 »

Seems odd. You should post the physics side of the code.
_hiya_
Posts: 4
Joined: Thu Aug 20, 2015 10:10 pm

Re: setLinearVelocity - object not moving

Post by _hiya_ »

btRigidBody* body = btRigidBody::upcast(pObject);
body->getWorldTransform().setRotation(btQuaternion(0, 0, 0, 1));
body->setLinearVelocity(linVel);
body->setAngularVelocity(btVector3(0, 0, 0));

body->setCcdMotionThreshold(extends[0]);
body->setCcdSweptSphereRadius(extends[0] * 0.9f);

extends is from bounding box of the mesh model
linVel is just forward vector of camera multiplied by speed value
Basroil
Posts: 463
Joined: Fri Nov 30, 2012 4:50 am

Re: setLinearVelocity - object not moving

Post by Basroil »

_hiya_ wrote: extends is from bounding box of the mesh model
linVel is just forward vector of camera multiplied by speed value
The forward vector is non-zero?

The GL demo app version of the shootbox does not use the camera orientation directly, rather it uses the camera position and target position as the forward vector, then normalizes it and multiplies it by a given speed. You should check DemoApplication.cpp line 562 for more information.
_hiya_
Posts: 4
Joined: Thu Aug 20, 2015 10:10 pm

Re: setLinearVelocity - object not moving

Post by _hiya_ »

forward vector is correct and the object spawns at the right position. ( I make it spawn 128 units in front of camera) but it just spins and doesnt move forward

maybe I am doing something wrong with gravity or other setup stuff setCcdSweptSphereRadius or setCcdMotionThreshold etc...

Any suggestions?
Post Reply