I know the question isn’t worded very well so, I’ll elaborate.
Say if the player is trying to destroy an object like a soda can for the sake of the question.
On one script the soda can has a variable for health say 100.
Then on the player script it says that if this has a tag or so of “Junk”
Then deal this value of damage and subtract it from the health of the Soda can.
I’m under the impression this has something to do with broadcasting, but I tried and I have no clue.
*None of the scripts below are existent yet this is just for future reference.
SodaCan.js
var health : int = 100;
function Update(){
curHealth;
}
Player.js
var junkDamage : int = 50;
var junkObj : GameObject;
function DestroyJunk (){
if(junkObj.tag == "Junk"){
DealDamage()?;
}
function DealDamge(){
var curHealth = health - junkDamage;
}
I am aware that this is no where at all accurate. I just need to know the logic behind it so I may apply it.