Movement Type Change

MrQuaid

Member
Hi, so what I am trying to do is change the players movement type when he has a weapon equipped. I have spent the past few days trying to get it to work with no success. I thought at first it would be simple like starting an ability but its not that easy. I use the Third Person Adventure as the main type, and I want to switch between that and Third Person Combat. I tried the MovementTypeSwitcher script and I can't quite get that to work. I get the error below for that one. At one point I added all the movement types and tried that script and it did switch to RPG, but not the other types. What's the best solution to change between the two types i listed above?

DivideByZeroException: Attempted to divide by zero.
Opsive.UltimateCharacterController.Demo.MovementTypeSwitcher.Update () (at Assets/Opsive/UltimateCharacterController/Demo/Scripts/MovementTypeSwitcher.cs:92)
 
The MovementTypeSwitcher component enables a state which then changes the movement type. If you don't want to go the state route you can change the movement type with UltimateCharacterLocomotion.SetMovementType.
 
Is there an example in the docs somewhere? I know how to get the players UltimateCharacterLocomotion but what is the type? Seems like there is more than just calling one line of code right?
 
I will work on updating the docs, you can get the type by using UnityEngineUtility.GetType:

Code:
UltimateCharacterLocomotion.SetMovementType(UnityEngineUtility.GetType("Opsive.UltimateCharacterController.ThirdPersonController.Character.MovementTypes.Adventure"));
 
Thanks again, I was able to get it to work perfect with that line of code, I just updated to match the movement needed.
 
I will work on updating the docs, you can get the type by using UnityEngineUtility.GetType:

Code:
UltimateCharacterLocomotion.SetMovementType(UnityEngineUtility.GetType("Opsive.UltimateCharacterController.ThirdPersonController.Character.MovementTypes.Adventure"));
Hello Justin,

In this way, the View Type will not change.

1. Will this cause any problems?

2, Although the View Type did not changed with the MovementType.But the result seem to be right.I don't feel the effect of viewType.Is that right?Or what does it do?

1604336700678.png
 
SetMovementType doesn't change the view type. Although this won't necessarily cause any direct errors or conflicts, you may end up with unexpected movement if it's connected to the camera in any way. You can call CameraController.SetViewType(typeName) to change the view type manually.
 
SetMovementType doesn't change the view type. Although this won't necessarily cause any direct errors or conflicts, you may end up with unexpected movement if it's connected to the camera in any way. You can call CameraController.SetViewType(typeName) to change the view type manually.
Hi Andrew, Thank you.
 
Top