Sign in to follow this  
Alundra

Safe ID for a sequencer or another link between objects

Recommended Posts

Hi,
When you want to do a Sequencer to have animation in a scene or cut-scene, you have to have a safe ID for objects.
Same things if you link one object in a component, for example a joint component to link physically 2 objects.
Using a unique ID counter is not safe because you wil not have the same ID when relauching and using name is not safe because the name is not unique.
The index of object in the scene can not be used too because the the scene is not sorted, if you remove one actor and add again in the scene, it's added at the end.
Is it better to sort the objets in the scene parent->child to always have a valid index ? But then if you remove one object all the index are moved too because of the shift in the array.
Any idea for this kind of stuff ?
Thanks

Edited by Alundra

Share this post


Link to post
Share on other sites

If you want to be able to generate IDs that are known to be unique, then you want GUIDs/UUIDs.

If you want to generate smaller IDs that you are pretty damn sure are unique (but without a strong guarantee), then you want hashes - perhaps the object name or asset path being hashed.

If you want IDs that are human-readable, then you want names, with some sort of namespacing or hierarchy to enforce uniqueness. (Like a filesystem.)

But often these problems don't arise at all, because an index, name, or pointer is sufficient, and can be created when needed.

Edited by Kylotan

Share this post


Link to post
Share on other sites

It sounds like you have already decided on a solution to use, then are struggling to apply it to a problem.  Several of the solutions you dismiss are commonly done. Fixed IDs and names in assets are frequently used because they can be controlled during development to never be duplicated.

What is the actual problem you are having? What are you trying to solve? What is the reason that your objects with IDs does not work?

Share this post


Link to post
Share on other sites

It's not about asset because the asset use unique path (basically it's a path from the disk with prefix replaced : Engine/, Content/ ....)
The problem is for game object, to link a game object to a property, for example to link two game object physically (the two have a rigid body component).
The game object linked on the property must be valid when save and open the scene, in other words, a serializable solution.
For a sequencer which animate the scene it's the same deal, it has to be serializable correctly.
Sequencer is just a link of game objects and animate the properties of components.

Edited by Alundra

Share this post


Link to post
Share on other sites

Okay, so you're specifically worried about IDs to objects that need to persist through a serialisation stage.

If you really need IDs that reference other objects in the data you're serialising, you can use whatever IDs are relevant at run-time; you just need to treat them as temporary when you load them, then run a post-deserialisation stage to fix them up and replace them with valid IDs.

(Maybe there's an easier way than this, but it's not a problem I encounter often.)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this