This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
+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 (174 points)

1 Answer

0 votes

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 (22,704 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 Frequently asked questions and 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 [email protected] with your username.