[BUG] Error on Weapons Not having a Preset for FirstPerson States

Tanman555

New member
After Importing TPC version 2.1.1 into my project, I noticed a small error about my weapons not containing a preset for First Person states.

Code:
Error: The state FirstPerson on Katana (Opsive.UltimateCharacterController.Items.Actions.MeleeWeapon) does not have a preset. Ensure each non-default state contains a preset.
UnityEngine.Debug:LogError(Object)
Opsive.UltimateCharacterController.StateSystem.StateManager:InitializeInternal(GameObject, IStateOwner, State[]) (at Assets/Opsive/UltimateCharacterController/Scripts/StateSystem/StateManager.cs:98)
Opsive.UltimateCharacterController.StateSystem.StateManager:Initialize(GameObject, IStateOwner, State[]) (at Assets/Opsive/UltimateCharacterController/Scripts/StateSystem/StateManager.cs:62)
Opsive.UltimateCharacterController.StateSystem.StateBehavior:Awake() (at Assets/Opsive/UltimateCharacterController/Scripts/StateSystem/StateBehavior.cs:27)
Opsive.UltimateCharacterController.Items.Actions.ItemAction:Awake() (at Assets/Opsive/UltimateCharacterController/Scripts/Items/Actions/ItemAction.cs:45)
Opsive.UltimateCharacterController.Items.Actions.UsableItem:Awake() (at Assets/Opsive/UltimateCharacterController/Scripts/Items/Actions/UsableItem.cs:121)
Opsive.UltimateCharacterController.Items.Actions.MeleeWeapon:Awake() (at Assets/Opsive/UltimateCharacterController/Scripts/Items/Actions/MeleeWeapon.cs:273)
UnityEngine.Object:Instantiate(GameObject, Vector3, Quaternion)
RTSCoreFramework.CharacterSpawner:SpawnCharacterPrefab(GameObject, String) (at Assets/RTSCoreFramework/RTSCoreFramework/Scripts/ExtraFeatures/CharacterSpawner.cs:59)
RTSCoreFramework.<GetReadyToInitializeAllyMember>d__14:MoveNext() (at Assets/RTSCoreFramework/RTSCoreFramework/Scripts/ExtraFeatures/CharacterSpawner.cs:79)
UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)

I currently only have the TPC v2.1.1 asset, so I don't know why it's complaining about first person state presets. I wonder where I would fix this issue, on the weapon or in the animator?

I'm currently using Unity 2018.3.5f1
 
The Fix was quite easy actually. In my character prefab, inside the Items GameObject near the root, I can find the Katana weapon that's mentioned in the error log. The Katana Item has a MeleeWeapon script, at the very buttom of the inspector there's a States array. For some reason, I had a State called "FirstPerson" with no preset defined.

MeleeWeaponFirstPersonStatesEmptyPreset.PNG

All I had to do is remove this state from the States list, and the error disappears when I press play.
 
My guess is that you used the UltimateCharacterControllerKatana prefab as a base instead of the ThirdPersonControllerKatana. I just checked and the ThirdPersonControllerKatana prefab does not have the first person state.

That actual warning though is harmless, it's mostly meant to notify you that there could be a potential issue with a missing state.
 
Top