Using the Character Controller Body's Tag Property

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
Alic
Posts: 39
Joined: Fri Jul 29, 2011 2:25 pm

Using the Character Controller Body's Tag Property

Post by Alic »

Specifically, the CollisionInformation.Tag property. Is there any way to use the CharacterController but still be able to use the body's tag property for tying together game logic? I was just trying to substitute in the CharacterController for the old SimpleCharacterController I've been using, and it seemed like it was going to work until I ran into this issue (my problem is that I'm already using the CollisionInformation.Tag property in event handlers all over the place).

Thanks for reading Norbo,

Alex.
Spankenstein
Posts: 249
Joined: Wed Nov 17, 2010 1:49 pm

Re: Using the Character Controller Body's Tag Property

Post by Spankenstein »

The .Tag property can be any class you desire.

This means that you can have the original properties in there plus the new properties you wish to have.

By creating a class that contains both original and new properties your problem should be solved.

Code: Select all

class MyNewClass
{
       // Original CharacterController.Tag parameters
       public float OldCharacterControllerTagProperty;

       // Your new parameters
       public float MyNewInformation;
}

// Create an instance for the .Tag
MyNewClass m = new MyNewClass

// Assign original CharacterController parameters and new parameters
m.MyNewInformation = 1f;

// Assign the class to the .Tag
CollisionInformation.Tag = m;
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Using the Character Controller Body's Tag Property

Post by Norbo »

In addition to the general solution above, the CharacterController systems expect a Tag that implements ICharacterTag. If you implement ICharacterTag on your tag object, the character can use it without modifications to other character systems.
Post Reply