Vulcan Posted July 28, 2014 Share Posted July 28, 2014 With Lua I could use Script:Collision( entity, position, normal, speed) and place out a box-trigger. Found a video illustrating this in Lua: But how could I do that in C++? I have looked in Entity.h for clues and I suspect it might be OnCollision(...) but not sure howto. Maybe this should be mentioned in the documentation with an example. Quote Link to comment Share on other sites More sharing options...
gamecreator Posted July 28, 2014 Share Posted July 28, 2014 I'm not sure but this might help too http://www.leadwerks.com/werkspace/page/documentation/_/command-reference/entity/entitycollisionhook-r64 Quote Link to comment Share on other sites More sharing options...
Vulcan Posted July 28, 2014 Author Share Posted July 28, 2014 Yeah looks like it could be some sort of callback. Your information lead me to Object::AddHock, so we will see how that come about. Quote Link to comment Share on other sites More sharing options...
AggrorJorn Posted July 28, 2014 Share Posted July 28, 2014 You can load your map and store all objects like this: Map::Load("Maps/mymap.map(), StoreWorldObjects()); and then in your storeWorldObjects() function you can look up triggers. (Note that CSG objects need an empty script or a mass for them to be picked up by the load hook.) void StoreWorldObjects(Entity* entity, Object* extra) { if(entity->GetKeyValue("name") == "Trigger") { //Make a new trgger or something trigger = new MyTrigger(); } } If you have made your own trigger class you can add a trigger hook in there: void MyCollisionHook(Entity* entity0, Entity* entity1, float* position, float* normal, float speed) { //A collision was made with the trigger } MyTrigger::MyTrigger() { entity->AddHook(Entity::CollisionHook, MyCollisionHook); } 2 Quote Link to comment Share on other sites More sharing options...
Vulcan Posted July 28, 2014 Author Share Posted July 28, 2014 You can load your map and store all objects like this: Map::Load("Maps/mymap.map(), StoreWorldObjects()); and then in your storeWorldObjects() function you can look up triggers. (Note that CSG objects need an empty script or a mass for them to be picked up by the load hook.) void StoreWorldObjects(Entity* entity, Object* extra) { if(entity->GetKeyValue("name") == "Trigger") { //Make a new trgger or something trigger = new MyTrigger(); } } If you have made your own trigger class you can add a trigger hook in there: void MyCollisionHook(Entity* entity0, Entity* entity1, float* position, float* normal, float speed) { //A collision was made with the trigger } MyTrigger::MyTrigger() { entity->AddHook(Entity::CollisionHook, MyCollisionHook); } Okay that is working but now I got another problem when hidding the triggerbox in LE (Appearance->Hidden). Can't the box be invisible? Quote Link to comment Share on other sites More sharing options...
AggrorJorn Posted July 28, 2014 Share Posted July 28, 2014 Apply the invisible material (materials//effects). Quote Link to comment Share on other sites More sharing options...
Vulcan Posted July 28, 2014 Author Share Posted July 28, 2014 Nice 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.