Raycaster to pick up a box.

ColeZero

03-06-2006 15:26:57

I'm currently working on a demo where i can pick up some boxes, like a gravity-gun^^ or cellfactor.So this is my code:


Vector3 dir, vec;
Quaternion orient = mCamera->getOrientation();
Vector3 pos = mCamera->getPosition();

vec = Vector3(0,0,-1);
dir = orient * vec;


ray = mScene->createRayCaster(pos,dir);
ray->cast();

HitBody = ray->mHitBody; //Need to check if no body is getting hit by the ray, else an error
would appear if you look into the "sky"
HitBody->addForce(dir * 100); //For testing



So with this code i can bounce a box, which i'm looking at, every time i click
So do you have any suggestions how i can pick up a box?
Maybe with HitBody->setGlobalPosition(EndofRay), or something?

danharibo

03-06-2006 16:09:27

maybe apply a force toward the xy coeds of the ray?

betajaen

03-06-2006 18:59:11

I have written the code to pick up boxes before using a Knimetic actor, but it does go through other static bodies. Salmod on the main forums used a specialised character controller to act as a hand which worked pretty well.

But for the Sci-Fi element:

You could use is a mixture of joints and initial force.

So you move the object towards you at an alarming speed, then when comes near the character then attach you and the character to a new joint, a fixed joint for example.

When 0.5 comes out I plan to refine picking up and moving bodies as a fine at, infact when it comes out the character controller demo would be very much like Half Life 2.

ColeZero

03-06-2006 21:40:13


When 0.5 comes out I plan to refine picking up and moving bodies as a fine at, infact when it comes out the character controller demo would be very much like Half Life 2.


That would be soo cool..

The thing i programmed is much more like a shoot impact..
if someone is shooting on a box, i use the raycaster and then i add a force to the body to simulate the impact..

betajaen

03-06-2006 21:52:11

The code seemed like it, the Tech Demo of 0.3.5 did this too.