Setting variable in prefab from a method called by prefab
Hi,
Could you please advise me how to change a variable in prefab from method called by the prefab?
This is how I call the method from prefab on collision:
public void OnCollisionEnter2D(Collision2D collision)
{
_GSScriptReference.EnemyCollision(transform.position, collision.gameObject.tag, collision, Lives, PointsForKillMe, gameObject);
}
From Method in different script I want to change variable Lives in the prefab which called the method. I tried several syntaxes, none works for me. Now I have something like this:
EnemyGameObject.GetComponent(FireballScript).Lives = Lives;
EnemyGameobject is the object reference ' gameObject' I got while calling the method -
Thanks so much for any help
Ukrutnik
Comment