Windows Standalone IL2CPP Fix, AI Optimizations, and Floating Point Precision Compromise

desertGhost_

New member
Hi. Great asset. Just have a few suggestions / questions.

Windows Standalone IL2CPP fix:
I found that when compiling with Unity 2018.3 for Windows Standalone IL2CPP I had to add || ENABLE_IL2CPP to the precompiler #if directive at the top of the AOTLinker file for the necessary AOT code to be produced.

AI Optimizations?
Are there any optimizations I can do when using UCC + Behavior Designer for AI?

I found that with just 7 agents that the CPU usage by UCC updating animators was quite high.

Some sort of Animator IK LOD (where you allowed the user to turn off certain IK's at certain distances) would be a great feature.

Floating point precision compromise:
I found that when going far away from the origin (1500+ meters) that the first person arms and weapon shake quite a lot. I fixed the shaking by scaling the First Person Pivot Object by a factor of 20 at run-time, adjusting the position springs to accommodate for the scaling, and disabling the first person arm / weapon meshes from receiving shadows (because the scaled meshes would otherwise have incorrect shadows).

Any suggestions / ideas of a better way to address this?

Thanks.
 
Hi @desertGhost_ I have the same issues relating to AI Optimization (I can't put more than 5-7 AI Agents on a i7 6 cores GTX1800 because the CPU usage drops quite a lot) and the first person arms and weapon shakes quite a lot at same distance than you (At 7.000+ m are like dancing :). Did you resolve this at least temporarily with the scaling / springs as you mention?

Thanks.
 
The shaking is hugely reduced when I scale the First Person Pivot Object (it is instantiated at run-time so this has to be done with a script) by a factor of 20, but I only have tested it out to 4000 m. It does however come with some unfortunate compromises: the first person arms and weapons cannot receive shadows as they would be incorrect, if your weapon uses a camera for the scope lense it will render from the wrong position and will need to be moved (out of the weapon hierarchy?), and any motions when running / sprinting for a given weapon will have to be tweaked in order to appear correct.

Attach this script to the main camera to scale the pivot at run time:

C#:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

//attach this to the main camera
public class FirstPersonObjectPivotScaler : MonoBehaviour
{
    [Tooltip("The scale factor to scale the arms. Adjust for your needs.")]
    public float scaleFactor = 20f;

    // Start is called before the first frame update
    IEnumerator Start()
    {
        yield return null; //wait for everything else to initialize

        var fpObjPivot = GetComponentInChildren<Opsive.UltimateCharacterController.FirstPersonController.Character.Identifiers.FirstPersonObjectPivot>();

        if (fpObjPivot != null)
        {
            fpObjPivot.transform.localScale = Vector3.one * scaleFactor;
        }
    }   
}

I would imagine simply scaling the weapon / arm models when creating the controller would be a simpler solution and should work as well (I'll have to try it)?

I haven't figured out how to optimization the AI yet without rewriting parts of UCC... for the time being I'll probably stick to our (lacking) in-studio AI controller solution.
 
Last edited:
Windows Standalone IL2CPP fix:
Thanks for the heads up! I'll include this fix in the next version.

AI Optimizations?
The next version, 2.1, contains some optimizations so you should see some improvement but you're correct in that you'll want to do some sort of culling with lots of agents. After 2.1 is released I am going to add a documentation page which describes optimization strategies but for right now this thread is a pretty good resource.

Floating point precision compromise:
The only other method that would work is to reposition the character closer to the origin when they get really far away but this doesn't work with all game types. You're correct in that the issue is caused by floating point precision at far distances. In one of the future versions I'd like to include the tiny hands as an option which would prevent you from needing to manually scale it.
 
Top