Einlander Posted October 26, 2014 Share Posted October 26, 2014 While making my game I ran into a situation where I needed to kill the player reliably and not depend on fall damage. The solution was to create a trigger that when the player touches it, they die. Kill_trigger.lua function Script:Collision(entity, position, normal, speed) if entity.script then if entity.script.health>0 then if type(entity.script.Hurt)=="function" then entity.script:Hurt(entity.script.health+1,"WORLD") end end end end WARNING: If the player is to FALL ON TOP of the trigger, the kill trigger MUST be almost paper Thin. Otherwise your dead body will keep bouncing as if were on a trampoline. I used it for when the player falls in the water. When they fall in the river they die/drown. 3 Quote Link to comment Share on other sites More sharing options...
Rick Posted October 26, 2014 Share Posted October 26, 2014 If you look at this trigger setup it has an OnEnter which is only fired once so you can use that to have any size and avoid having the collision keep getting called. http://leadwerks.wikidot.com/wiki:collision-enter-exit 1 Quote Link to comment Share on other sites More sharing options...
Einlander Posted October 26, 2014 Author Share Posted October 26, 2014 If you look at this trigger setup it has an OnEnter which is only fired once so you can use that to have any size and avoid having the collision keep getting called. http://leadwerks.wikidot.com/wiki:collision-enter-exit I have ran across that, but in my case I needed it to fire for every entity that enters it. Using the wikidot script, I can push an entity into it and then I have a free pass to go through without dying. It gets worse if they make it so it just hurts people and not kill them. For example I wade into acid and then people chase after me. I would get all the damage and no one else would. I do have a collision trigger script that is capable of tracking multiple entities entrances, exits and if they are just idling in the trigger. It is complicated due to me coding it to be network multiplayer friendly. 1 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.