x


Water is killing player when enemy enters it

Im trying to make it so that when player enters water I die but when enemy enter it I don't. I currently have this code which when I enter the water it kills me, and when my enemy enters the water it kills me.

//DamageTrigger.js: A simple, variable damage trigger which can be applied to any kind of object.  
//Change the damage amount in the Inspector. 

var damage: float = 20.0;
var playerStatus : Widget_Status;

function OnTriggerEnter(){
    print("ow!");
    playerStatus = GameObject.FindWithTag("Player").GetComponent(Widget_Status);
    playerStatus.ApplyDamage(damage);
}

@script AddComponentMenu("Environment Props/DamageTrigger")
more ▼

asked Aug 28 '11 at 08:50 PM

Davidflynn gravatar image

Davidflynn
61 24 49 56

Need some help here im stumped bad this should be extreemly easy.

Aug 28 '11 at 09:32 PM Davidflynn
(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

not sure if I understand what's going on. I'm guessing Player dies if anything enters the water?

The following is not tested. Just something to nudge you in the right direction...

function OnTriggerEnter (other : Collider) {  var player = GameObject.FindWithTag("Player");  if(other == player.collider)  {  print("ow!");  playerStatus = player.GetComponent(Widget_Status);  playerStatus.ApplyDamage(damage);  } }

Greetz, Ky.

more ▼

answered Aug 28 '11 at 09:50 PM

SisterKy gravatar image

SisterKy
2.5k 33 42 60

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x560
x394
x304
x64

asked: Aug 28 '11 at 08:50 PM

Seen: 872 times

Last Updated: Aug 28 '11 at 09:50 PM