Understanding GUIDs and their usage

#1
I've started to study the new templates in the 5.4 preview and came across GUIDs. I've done basic research on them but have trouble understanding exactly what their purpose is. In the first person shooter template, why does the SpawnPoint have a GUID but not the player or bullet? When I go to create a new entity, what determines whether I should give it a GUID or not?

Edit: I think I have a better understanding now. The player class doesn't have a GUID but the character controller it borrows from does. So it seems to me if you want to create and register a component, you need to create a GUID?

I have another question about GUIDs. I was looking into CharacterControllerComponent.h and there's a few lines of code where a component is referenced by its GUID. Well, at least I think that's what's happening:

Code: Select all

            // Mark the Rigid Body component as incompatible
            desc.AddComponentInteraction(SEntityComponentRequirements::EType::Incompatibility, "{912C6CE8-56F7-4FFA-9134-F98D4E307BD6}"_cry_guid);


How do you find another component's GUID? Where are all of the default components stored? Where do I find the rigid body component?

Re: Understanding GUIDs and their usage

#2
My understanding is that GUIDs are only needed when you want to expose the component to the editor and / or serialise it to disk / network. The player class should never be exposed to the editor, since it's never valid for someone to just stick another player into the save game. The same applies to the bullet, which is only ever spawned by the player.

Default components can be reference by including e.g.

Code: Select all

#include "DefaultComponents/Geometry/AdvancedAnimationComponent.h"


You should be able to find a component's guid by calling it's IID() function.

Re: Understanding GUIDs and their usage

#5
quasarwei wrote:I've started to study the new templates in the 5.4 preview and came across GUIDs. I've done basic research on them but have trouble understanding exactly what their purpose is. In the first person shooter template, why does the SpawnPoint have a GUID but not the player or bullet? When I go to create a new entity, what determines whether I should give it a GUID or not?

Edit: I think I have a better understanding now. The player class doesn't have a GUID but the character controller it borrows from does. So it seems to me if you want to create and register a component, you need to create a GUID?

I have another question about GUIDs. I was looking into CharacterControllerComponent.h and there's a few lines of code where a component is referenced by its GUID. Well, at least I think that's what's happening:

Code: Select all

            // Mark the Rigid Body component as incompatible
            desc.AddComponentInteraction(SEntityComponentRequirements::EType::Incompatibility, "{912C6CE8-56F7-4FFA-9134-F98D4E307BD6}"_cry_guid);


How do you find another component's GUID? Where are all of the default components stored? Where do I find the rigid body component?

mknmknmknjk is correct, it is a very light form of run-time type identification, and is only required to be used/specified _once_ - in your types interface.

fury22uk wrote:So if I want to register new component and expose it for the editor what do I do? I used ReflectType method, but it requires Guid and I have no Idea how to create one. Can I just think up some random guid?

You don't have to use the uid, simply use the interface that defines that uid - I posted an example in your thread specifically asking this ;).
For your components, you can used visual studio to generate a unique GUID by going Tools->Create GUID->4 (registry format).
Uniflare
CRYENGINE Community Coordinator
Here to help the community and social channels grow and thrive.

My personal belongings;
Beginner Guides | My GitHub | Splash Plugin

Re: Understanding GUIDs and their usage

#7
fido9dido wrote:are these numbers in GUID reserved? Can I change them in the same format???

Can you rephrase your question more explicitly? I don't understand what you are asking.

The GUID internally are stored as a 2-part 128bit unsigned integer. More specifically;

Code: Select all

uint64 hipart;
uint64  lopart;


So you can either pass the uint64's in directly eg,

Code: Select all

auto uid = CryGUID(5763014294466489576, 15454999660199490705);


Or use a helper method such as the compile-time constexpr:

Code: Select all

auto uid = "{912C6CE8-56F7-4FFA-9134-F98D4E307BD6}"_cry_guid;

Again, this level of knowledge is not necessary.
All you need to do is provide a unique id for each type that inherits ICryUnknown. That is all.

You can use the Tools->CreateGUID option in Visual studio, to be honest, You can make the GUID however you like, it will be extremely rare to get any clashes unless you are manually copy/pasting the GUID or w/e. Just make sure the string is in the correct format supported by CryGUID constructor/helper functions.

To use the functionality, you do not need to know the GUID, only have access to the types declared interface (which has the GUID ofc). Check out viewtopic.php?f=14&t=1518#p6211 for an example.

hope this clarifies things,
cheers
Uniflare
CRYENGINE Community Coordinator
Here to help the community and social channels grow and thrive.

My personal belongings;
Beginner Guides | My GitHub | Splash Plugin

Who is online

Users browsing this forum: No registered users and 2 guests