How to set MovementType manually via script

RamRod

New member
Hey, I have several character prefabs and created a modular spawn script that instantiates a prefab and adds all the needed components from UCC, but currently it fails on MovementType not being set.

I'm trying to set it via:

locomotion.SetMovementType(typeof(Opsive.UltimateCharacterController.ThirdPersonController.Character.MovementTypes.Combat));

but it won't set it up, seems like it's trying to TryGetValue out of the m_MovementTypeNameMap which isn't poplated so it fails. How do I populate the MovementTypeNameMap or what would be a better approach to set movement manually via script.

Thanks
 
Okay seems I've been able to move further with this script:

var type = typeof(Opsive.UltimateCharacterController.ThirdPersonController.Character.MovementTypes.Combat);
var movementType = Activator.CreateInstance(type) as MovementType;

locomotion.MovementTypes = new MovementType[] { movementType };
locomotion.SetMovementType(type);
 
Take a look at the UMA integration for a good example of setting up the character at runtime. It uses the CharacterBuilder class in order to add objects at runtime.
 
Top