Jump to content

Simple Kill Trigger


Einlander
 Share

Recommended Posts

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.

  • Upvote 3
Link to comment
Share on other sites

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.

  • Upvote 1
Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...