cassius Posted July 20, 2011 Posted July 20, 2011 I hve been using EntityDistance to trigger off events mainly because I don't understand collisioncallback. So maybe someone can halp. :ets suppose I have a character called mycharacter and a door called door01. I want door01 to open when mycharacter collides with it. I know the code for opening the door its just the callback code I need. I have checked the wiki but I need actual code. Quote amd quad core 4 ghz / geforce 660 ti 2gb / win 10 Blender,gimp,silo2,ac3d,,audacity,Hexagon / using c++
cassius Posted July 21, 2011 Author Posted July 21, 2011 Anybody? Quote amd quad core 4 ghz / geforce 660 ti 2gb / win 10 Blender,gimp,silo2,ac3d,,audacity,Hexagon / using c++
Canardia Posted July 21, 2011 Posted July 21, 2011 #include "engine.h" int DoorCollision(TEntity e1, TEntity e2) { if(GetEntityType(e2)==1) // only interested in balls AddBodyForce(e2,Vec3(0,1000,0)); return 0; } int main(int argc, char* argv[]) { Initialize(); Graphics(800,600); CreateFramework(); DebugPhysics(1); TBody door=CreateBodyBox(1,2,0.3); MoveEntity(door,Vec3(0,1,0)); SetBodyMass(door,1); EntityType(door,2); TBody ball=CreateBodySphere(); MoveEntity(ball,Vec3(0,2,-8)); SetBodyMass(ball,1); EntityType(ball,1); TTerrain terrain=CreateTerrain(128); EntityType(terrain,3); Collisions(1,2); // ball with door Collisions(1,3); // ball with terrain Collisions(2,3); // door with terrain TCamera cam=GetLayerCamera(GetFrameworkLayer(0)); MoveEntity(cam,Vec3(0,2,-10)); SetEntityCallback(door,(BP)DoorCollision,ENTITYCALLBACK_COLLISION); AddBodyForce(ball,Vec3(0,0,500)); while( !AppTerminate() and !KeyHit() ) { UpdateFramework(); RenderFramework(); Flip(); } return Terminate(); } 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 ■
cassius Posted July 21, 2011 Author Posted July 21, 2011 Many thanks. Quote amd quad core 4 ghz / geforce 660 ti 2gb / win 10 Blender,gimp,silo2,ac3d,,audacity,Hexagon / using c++
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.