destroy enemy with tag attached

i want to make a script with my scripts i have now but they dont work i want to mke it so when my WEAPON collides with the ENEMY then the enemy gets destroyed but heres the catch its going to have health too and im kind of stuck cause i have an ontriggerenter function that doesnt work(had it working at one point then screwed it up) and right now i just go right through the enmy please help im stumped on this ive tried a lot of things but none of them work(including other unity fourms) oh by the way here are my scripts dont laugh when you see them though i have no idea what im doing one script is correct and the other is just terrible and doesnt work :

#pragma strict

function OnTriggerEnter (Collider) {
if (Input.GetButtonDown("Fire1")){
if(gameObject.tag == "mace") {
Destroy(gameObject);
}
}
}
#pragma strict
var thedammage : int = 50;
var Distance : float;
var maxdistance : float = 1.5;
var themace : Transform;
function Update ()
{
if (Input.GetButtonDown("Fire1"))
{
themace.animation.Play("Attack");
var hit : RaycastHit;
if (Physics.Raycast (transform.position, transform.TransformDirection(Vector3.forward), hit))
{
Distance = hit.distance;
{

hit.transform.SendMessage("ApplyDammage", thedammage, SendMessageOptions.DontRequireReceiver);
}
}
}
}

You’re doing WAY too complicated of a task. I know that everyone wants to make a game and get right into doing the thing they love, but you just can’t. I REALLY hope the community backs up what I’m saying here so you don’t think I’m just trying to get out of helping you. Take is slow. Think of a game idea that you can accomplish in one week and make it. Even if that means you make a ball roll down a ramp into a hole. Just get it done, learn the lessons, then throw it away and start over with a new idea that you can do in a week or two. Then pick a project that might take a month. Then 2 months… At that point you’ll get a good feel for what you can handle and what you can make.

To further my point, think of any other thing.

First time cooks make peanut butter and jelly and mac n cheese. Someone who has never cooked before doesn’t go cater an event for the president.

Carpenters start off building mail boxes and bird houses. Heck my first project was a box for my tools. Then I made a cutting board. A cutting board. It didn’t even have the drip catches along the edges.

Firefighters start off shadowing and going to school, and would never be asked to set an IV on their first call.

Programmers start off with displaying Hello World to the screen. A first time programmer would never try writing something like accounting software.

First time game developers make a pong game with one paddle and if you hit the opposite wall you win. They would never try to make a fully fledged RPG with maces and animation based hit detection.

I hope you see my point. Don’t be discouraged. Learn learn learn! You’ll gain massive respect from the community if you ask a question about how to go about handling trigger colliders, because we’ll know you’re new and know you’re trying to learn something reasonable. :slight_smile:

Good luck sir. No shame in abandoning this task and starting something simpler. In fact you’ll be received will applause if you do.

Whew, that was long winded. My bad! Haha.

I’ll back @jtsmith1287 here and add that a lot of things that appear trivial (weapon hits enemy, enemy takes damage, enemy ultimately dies) are actually VERY involved when you actually try to make it happen yourself in a game engine.

Take a look at some of the complete games in the asset store and challenge yourself to understand how each part of it works, what happens when bullets hit a spaceship, etc. Then challenge yourself to change one feature. Then challenge yourself to add a new feature.

1 Like

If you’re like me and just can’t stand it any longer, Kurt’s idea is actually really great. Grab a completed game, pick a feature, and try to change it without breaking the game. Not for the faint of heart. :wink: