Page 1 of 1
Character Controller and Tag property.
Posted: Sat May 18, 2013 11:37 pm
by Stevemata
Hi Norbo, thanks in advance
My raycastresult.hitobject.tag is returning a "CharacterSynchronizer" object, rather than the string I set to specify that this particular object is the player.
Please expalin exactly what's going on here. Is there an alternative or work around for this issue?
Re: Character Controller and Tag property.
Posted: Sat May 18, 2013 11:51 pm
by Norbo
The hit object returned by a ray cast is a BroadPhaseEntry; in this case, the ray hit the collidable object associated with the body of the character. That particular Tag property is filled by a synchronization object required for characters to function properly in a multithreaded context.
If you set a tag and don't see it, chances are you set the Entity.Tag property instead. The Entity and its collidable (stored in the Entity.CollisionInformation property) are different objects, so their Tags are separate as well.
To retrieve a Tag set in the Entity.Tag property, you can cast the hit BroadPhaseEntry to an EntityCollidable. The EntityCollidable.Entity property gets you the entity, and then the Entity.Tag property gets you your tag.
You could also store your own data in the BroadPhaseEntry.Tag (i.e. CharacterContorller.Body.CollisionInformation.Tag) by creating your own subclass of the CharacterSynchronizer type or, more generally, by implementing the ICharacterTag interface.