Very simple collision death

Hi guys, I need a little help with scripting. I’m not a coder myself, and since I’m a one man team it means the progression to coding is slow. I’m doing a game jam with a very simple game, and so far its going very well. However, I’ve come across a bit of a problem. I can’t figure out how to (and also cannot find)a script which would basically mean if anything collides with my players collider, then the player gets destroyed. It would need to attach to only the head part of my character (on its rig), which has of course a collider and rigibody of its own.
If anyone could help that would be fantastic. I know I should be more knowledgeable about coding and that it’s annoying to have people come to you with questions without any knowledge of what it means, I completely get that, but I am learning, its just slow.

Thanks guys

This answer assumes that your character is made up of a bunch of different pieces, considering it has a “head part.” Make sure the other objects that collide with your player have a collider of their own. Set all colliders to “Is Trigger.” Add rigidbodies to your player and all objects that can kill it. Make sure “Use Gravity” is unchecked on all rigidbodies (unless you want to use gravity).

Create a new C# script. Add this code to the script BELOW the Update function. NOT inside of it:


//Drag your MAIN player object into the variable below AFTER you’ve attached this script to your player’s head

public Transform player;

void OnTriggerEnter(Collider other) {




Attach the script to your player’s head. This should do the trick, if I correctly understand they way you have your player set up, which is that he has different objects making up his body, all children of a main object. If your player is just ONE object, simply change Destroy(player.gameobject); to Destroy(gameobject); and get rid of the player Transform variable.