CharacterLocomotion.cs cannot add 3rd party assemblies

SpawnStorm

New member
I've posted a similar report in the Discord - https://discord.com/channels/476506682382483456/478012956899147797/901591267803267082

Basically, I'm attempting to modify the source for CharacterLocomotion.cs. However, if I add a 'using [xyz Namespace]' to the file, it is not detected. Unity also throws an exception on compile, so this isn't a limitation of the IDE.

Repro steps:
Create a fresh 3D (legacy pipeline) project (Unity 2021.1.3.f1, but others have been tested).
Import TPC 2.4.2 (latest)
Import Final IK 2.1 (latest)
Open CharacterLocomotion.cs
Add "using RootMotion.FinalIK;" on line 20 (just after "using UnityEngine;")
Observe that IDE and Unity do not recognize the assembly reference.
Create a new script in Assets folder
Add "using RootMotion.FinalIK;"
Observe that it accepts the assembly reference.

Error:
Assets\Opsive\UltimateCharacterController\Scripts\Character\CharacterLocomotion.cs(20,11): error CS0246: The type or namespace name 'RootMotion' could not be found (are you missing a using directive or an assembly reference?)

Notes:
I've tested this on Odin ("using Sirenix.OdinInspector.Internal;") - this works.
I've tested this with Chronos ("using Chronos") - this doesn't work.
If CharacterLocomotion.cs is moved to Assets folder, all tests work, but this will of course break other things from what I've read in the Discord.
This appears to match a behavior from a long time ago where scripts within an Editor folder will fail to detect non-Editor script. However, the path for CharacterLocomotion.cs is not in an Editor folder.
Additionally, both FinalIK and Odin exist within the Plugins folder, whereas Chronos does not. Placing Chronos into a Plugins folder does not change the above behavior.
 
Last edited:
I would report this to Unity - the character controller doesn't do anything specific with compiling so it's up to Unity to determine the correct compilation order.
 
Found the answer.

UCC has an Assembly Definition Asset at the root level of the package (Opsive.UltimateCharacterController). All scripts below that folder must reference scripts within the package.
The exception to this is if you change the Assembly Definition References list to include another assembly.

I needed to create an Assembly Definition for Chronos, and use the existing RootMotion.FinalIK assembly definitions.

Once I added both of those to Opsive.UltimateCharacterController.asmdef CharacterLocomotion.cs was able to identify the 3rd party scripts.

Few things to note:
Unity docs on Assembly Definitions - https://docs.unity3d.com/Manual/ScriptCompilationAssemblyDefinitionFiles.html
Unity compilation order (didn't apply in this case) - https://docs.unity3d.com/Manual/ScriptCompileOrderFolders.html
 
Top