Hi, here is my problem,
I have a script on my character with the variable “vie” (life of the character), I want to import this variable on my ennemy script to change the damage of my enemy.
Here’s my character script
var vie = 100;
function OnCollisionEnter (hit : Collision)
{
Debug.Log (vie);
if(hit.gameObject.tag == "Enemy")
{
vie -= 10;
Debug.Log (vie);
if (vie <= 0){
Destroy(gameObject);
}
}
}
here is my enemy script
var speed = 10;
var joueur : GameObject;
var vie:vieperso = GetComponent(vieperso);
function Update ()
{
var distance = Vector3.Distance (joueur.transform.position, this.transform.position);
if (joueur != null)
{
if (distance < 2)
{
if (distance < 7)
{
Debug.Log (vie);
vieperso.vie -= 20;
}
}
else
{
this.transform.position += (this.joueur.transform.position - this.transform.position).normalized * this.speed * Time.deltaTime;
}
}
else
{
}
}
But I have this error An instance of type ‘vieperso’ is required to access non static member ‘vie’.
thx for anyhelp