[resolved] Communicate Transform position between two objects

Hi,

I currently have two classes : Character and zombie.
I would like to give to my zombie my character position.

This is my character class :
public class Character : MonoBehaviour{

public Transform GetMyPosition(){
return this.transform;
}

}

And there is my zombie class :
public class zombie : MonoBehaviour {

public Transform origin;
public Character character;

void Update () {
deplace ();
}
void deplace(){
//Vector3 destination = cible.position;
Vector3 alienPos = origin.position;

origin.LookAt (character.GetMyPosition());

}
}

Problem is that actually, zombies are looking at 0.0.0 : my original position, and they keep looking at 0.0.0 when i am mooving.

This is how i linked ressources :

Thank you for your help !

You just need the Characters position from the zombie script?

Use

Private Transform _player;

void Start()
{
_player = GameObject.Find(“Player”).GetComponent();
}

To get the position of the player: _player.position

1 Like

Great, that works !
Thank you :slight_smile:

1 Like