Looking for a workaround, since we cannot get a sprite position (SOLVED)

Hi everyone,

I have a really simple GameObject, with a script and a sprite attached to it.

I want to create an arrow gui node that points to a specific position on that GameObject. I thought I could create a dummy sprite, place it where I want, and fetch its position to spawn my gui node.

However, we cannot access a sprite position. What other options do I have for this?

Thank you!

Could you use a parented game object and access it’s position instead of the sprite position?

1 Like

Yeah I thought about that, but is there a way to do that from the Outline window, or is that code only? ( I would have liked to not hardcode it )

Sure. If you’re working in a collection then it’s a matter of drag’n’drop to change the game object hierarchies:

1 Like

Oh, right, I was not in a collection when I tried to do that, only in the GO itself. Allright, thanks dude!

1 Like

Is there a way to get the children of game object from the script? go.get( parentUrl, “children” ) does not do the trick…

Nope, there’s currently no way for the engine to provide that information.

Okay, I thought I read the “children” property could be fetched. I’ll track it myself. Thanks

No, there is nothing like that exposed. For gui nodes there’s gui.get_parent() and gui.set_parent() and for game objects there’s the set_parent message.

thanks, and since we’re on this subject…

get_position() on my child object seems to return its local offset. Is there anything built in to get its world transform if its parent has rotated? Or do I need to do it manually?

Yup, we got you covered there:

It’s all in the API reference for the go namespace.

3 Likes