+1 vote

So, I don't know if I understood it very well; I can receive an EncodedObjectAsID from an action that my player does, but can I convert that into information about which Object it is?

I tried to look in the documentation and I confess I was a little confused.

Thanks people.

in Engine by (170 points)

1 Answer

–1 vote

I've never used this before (and I can't test it ATM), but from the docs, I'd expect it to work like this:

Assuming you have a valid EncodedObjectAsID...

  • It should have an id property. That's the same value returned by calling get_instance_id() on the original object

    • You can pass that id value to instance_from_id(id)
    • That will return the object instance represented by the passed id

Untested, but if your original EncodedObjectAsID is stored in myObject, I'd think this would return the original object:

var org_object = instance_from_id(myObject.id)
by (10,856 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.