Hey Guys,
I am trying to send a message from an enemy to the player during a send message. What I want to do is have the player look at the enemy when he is hurt (actually he is not hurt, he is blocking and that is why facing the enemy is so important).
He is an example of my problem
// Called in the enemies component
SendMessage ("ApplyDamage", 5, rootModel.transform);
// In the player's component
function ApplyDamage (damage : float, enemy : Transform) {
print (damage);
transform.LookAt(enemy);
}
I get an error which says basically that SendMessage will not send a transform. Is there anyway you can think of to get around this?
Cheers
Ergs707``
The error message isn’t about SendMessage not sending a transform, which it has no problems doing. The issue is that you can only use one parameter.
–Eric
Thanks Eric. That makes sense. I guess I can use two sendmessages, one to set a public variable for the transform of the enemy and a second to send the damage. Then the apply damage function can use both the variables. It is a bit clunky though. It would be great if it could send more than one.
Note: Alternative I could also use a getcomponent for the player’s attack script and see whether he is blocking and then call differing functions depending on blocking or taking damage, but it is really just as ‘clunky’.
Thanks again for the quick reply.
Cheers
-Ergs
Or you can make a class that contains a float and a transform, and use that with SendMessage.
–Eric