So, this is quite a hard thing to describe in the question name, I’m really sorry if it’s long and inaccurate. Anyway:
I’ve got 2 players in a game. Both have a collider and a series of attacks that draw a ray.
There is a script in which I make them do specific animations depending in the button pressed and there is one function which plays an animation only when one player is hit by another. Basically, imagine your common fighting game and when one punches the other, the other bends from pain.
I started working with making the health bars for them, again, in a fighting game manner, and succeeded to make a variable playerhealth and in one function wrote many if statements that make a GUITexture change in lenght. It looks something like if{playerhealth==75f){change the image to represent that health}. It all works and I have no trouble in those statements, but the tricky thing is this: in the inspector FirstPlayer has a public texture to which I assign the health bar image and when the FirstPlayers collider ir touched by other players ray he plays the needed animation and his health bar also changes. Then I opened the SecondPlayer in inspector and opened the same script they both share, but there the GUITexture was not assigned, so I assigned another one. Now, this is where the problem begins:
FirstPlayer hits the other one and the texture behaves as the one of the FirstPlayer.
So, I need a way to count the health of both characters individually. Thought of making separate scripts, assign them to the players and inside them call the function to play the animation of the one who was hit and then add the repositioning ifs to change the healthbar. When I did that or very similarly, I received an error which said I can’t use the function because the script security level is high.
I tried to make it as clear as I can.