Character Controller and Tag property.

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
Stevemata
Posts: 33
Joined: Sat Mar 17, 2012 11:11 pm

Character Controller and Tag property.

Post 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?
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Character Controller and Tag property.

Post 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.
Post Reply