How to access CharacterControl of a node

Hey mates! I am attempting to access the CharacterControl of a node but I do not know how. I added the control through node.addControl(control) but I don’t understand how to use .getControl (if thats what you use) in order to access the control again. If anybody can help me understand this, that would be great!

CharacterControl character = node.getControl(CharacterControl.class);

there can only be one control of a certain class. so controls are retrieved by passing the class as a parameter.

AppStates work the same way.

2 Likes

I knew there must have been an easy way to do this. Thanks for your help!

1 Like
@icamefromspace said: CharacterControl character = node.getControl(CharacterControl.class);

there can only be one control of a certain class. so controls are retrieved by passing the class as a parameter.

AppStates work the same way.

This is not a requirement in either case. You can add as many of the same type of class as you want… they are just harder to retrieve. Most controls won’t be happy to share a spatial with another instance of themselves but for app states it’s more common. For example, I have ViewPortAppState that I use to manage a viewport. I might add as many of these app states as I have viewports.