Kotov72rus Posted December 15, 2012 Share Posted December 15, 2012 Hi, there is a character "name=controller" and the object box "name=box_test". How to determine the collision with box?, and then perform the desired action. Quote Link to comment Share on other sites More sharing options...
macklebee Posted December 15, 2012 Share Posted December 15, 2012 If the box has an object script you can use the inherent collision callback (as shown in the template.lua script) and check the collision type given for the controller to drive the desired action. Granted this could be done using the collision callback in any other language as well. 1 Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
gamecreator Posted December 15, 2012 Share Posted December 15, 2012 The wiki has the simpler, clearer and more thorough example for Collisions Callback, here: http://www.leadwerks.com/wiki/index.php?title=EntityCollisionCallback 1 Quote Link to comment Share on other sites More sharing options...
Kotov72rus Posted December 15, 2012 Author Share Posted December 15, 2012 Thanks Quote Link to comment Share on other sites More sharing options...
Kotov72rus Posted December 16, 2012 Author Share Posted December 16, 2012 Why does not work this method? Without checking the name, works with all objects, that are currently in contact with the object. void _stdcall EntityCollisionCallback( TEntity entity0, TEntity entity1, byte* position, byte* normal, byte* force, flt speed ) { if(GetEntityKey(entity1,"name")=="test_box") { HideEntity(entity1); } } //Entity box SetEntityKey(test_box, "name","test_box"); //Controller SetEntityKey(Controller, "name","controller"); SetEntityCallback(Controller,(byte*)EntityCollisionCallback,ENTITYCALLBACK_COLLISION); Quote Link to comment Share on other sites More sharing options...
DaDonik Posted December 16, 2012 Share Posted December 16, 2012 The solution is pretty simple, but not obvious if your are not used to C++. You just can't compare a char* and a string. if(GetEntityKey(entity1,"name")=="test_box") Where GetEntityKey(...) is returning a char*. One way to do it would be to convert the char* to a string and then compare the two strings: std::string strEntityName = GetEntityKey(entity1,"name"); if (strEntityName =="test_box") { ..... } if the compiler complains about the std::string, just include the string header: #include <string> 2 Quote (Win7 64bit) && (i7 3770K @ 3,5ghz) && (16gb DDR3 @ 1600mhz) && (Geforce660TI) 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.