Page 1 of 1

Using the Character Controller Body's Tag Property

Posted: Sat Jul 07, 2012 9:20 am
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.

Re: Using the Character Controller Body's Tag Property

Posted: Sat Jul 07, 2012 10:45 am
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;

Re: Using the Character Controller Body's Tag Property

Posted: Sat Jul 07, 2012 4:10 pm
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.