ParaToxic Posted May 15, 2011 Share Posted May 15, 2011 Hey Guys , i want to chage in our little FPS Game the bullet as Bodies to Raycasting as in the LE Editor.But somehow it does not work ,to pick Bodies with CameraPick und Add Force to them. I have written : if(CameraPick( &pick,cam,Vec3(GraphicsWidth()/2,GraphicsHeight()/2,1000),0)) { AddBodyForce(pick.entity,Vec3(0,0,1)); //That is only for testing } and i become a error,when i shoot to a oildrum. Why is that so? Thank you Quote Link to comment Share on other sites More sharing options...
Canardia Posted May 15, 2011 Share Posted May 15, 2011 You are picking the mesh, and trying to add force to a mesh. You must add the force to the body instead, which is the parent of the mesh: if(CameraPick( &pick, cam, Vec3(GraphicsWidth()/2,GraphicsHeight()/2,1000), 0 )) { AddBodyForce( GetParent(pick.entity), Vec3(0,0,1) ); //That is only for testing } However, if your mesh is in a deeper hierarchy of the model, like a finger attached to a hand attached to an arm attached to the torso, then you need to use GameLib's GetMeshModel(pick.entity) instead of just GetParent(pick.entity). Quote ■ Ryzen 9 ■ RX 6800M ■ 16GB ■ XF8 ■ Windows 11 ■ ■ Ultra ■ LE 2.5 ■ 3DWS 5.6 ■ Reaper ■ C/C++ ■ C# ■ Fortran 2008 ■ Story ■ ■ Homepage: https://canardia.com ■ Link to comment Share on other sites More sharing options...
DaDonik Posted May 15, 2011 Share Posted May 15, 2011 Picking only works on the mesh and not the body. So in your case you try to add a force to a mesh. This function will return the model/body of your picked mesh: TModel GetMeshModel(TEntity _Entity) { string strClassname; while (_Entity != NULL) { strClassname = GetEntityKey(_Entity, "class"); if (strClassname == "Model") { return _Entity; } _Entity = GetParent(_Entity); } return NULL; }; Then you can pick your entity like that: TEntity GetPickedEntity(TEntity _Entity, float _fRange, TPick& _PickData) { TEntity ReturnEntity = NULL; if (EntityPick (&_PickData, _Entity, _fRange, 0.01F)) { ReturnEntity = GetMeshModel(_PickData.entity); } return ReturnEntity; }; Quote (Win7 64bit) && (i7 3770K @ 3,5ghz) && (16gb DDR3 @ 1600mhz) && (Geforce660TI) Link to comment Share on other sites More sharing options...
ParaToxic Posted May 15, 2011 Author Share Posted May 15, 2011 Thanks you very much,now it works Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.