Get player position(SOLVED)

I’m trying to get the position of a player game object withing my enemy code then simply printing it to see if it works.
*
Self.playerpos = go.get_position("#player")
Print(self.playerpos)
*
however it keeps printing it’s own position

Try this instead:

self.playerpos = go.get_position("/player")

The hash # symbol denotes a component within the same game object - which is why you’re getting the enemy position back.

1 Like

I tried but it gives me an error saying /player not found

What is the id of the player game object?

It’s just called player

You need to figure out what the correct address of the player is. The absolute address includes the sum of all the collections that it’s in. I suggest you re-read the Addressing Manual so you know how it works. The easy way to check is to put print(msg.url()) in the player script somewhere (like init()).

3 Likes

Thanks that fixed it

1 Like