Aim Assist

Luke

Member
Hi Justin,

I'm hoping you can help me once again.

I am having an issue where the aim assist target keeps getting lost.

I checked the 'HasTarget' bool and can see in debug that it flickers from true > false repeatively. This results in the camera snapping back to the target and the camera never smoothly follows the target.

Have you seen this before, I hope you can help me get the aim assist working smoothly again.

Thank you for your time!
 
For some strange reason - If in the editor at runtime - I change the state on the crosshairs monitor to the 2.5D (HideCursorPreset) the camera will follow smoothly as expectd :(
 
Weird.

Double check that you've followed these setup steps properly: https://opsive.com/support/documentation/ultimate-character-controller/camera/aim-assist/

Are you getting any error/warning messages? Compare your setup to the demo scene and see if you can you reproduce this within the demo scene itself. Are you able to step through AimAssist.cs (with console logs/breakpoints in SetTarget) to see where the issue is with the target getting set and un-set?

In particular take a look at the code starting from line 142 "if (m_TargetHumanoidBone) {...". Perhaps your target is a humanoid, but doesn't have its animator or bone transform set properly, which would cause line 145 "m_Target = animator.GetBoneTransform(m_HumanoidBoneTarget);" to return null.
 
Hi Andrew,

Thank you for your response.

The target is a non-humaniod and I have left that option unchecked.

There is no warning errors regarding the issue unfortunately. The set up is correct as far as I know, as when I switch the state on the crosshairs monitor script the camera follows smoothly as you would expect. It is just the aim assit doesn't keep it's target set.

I have played with all the input fields and none of them keep the target.

It is so far, only when I switch from the default state to the 2.5D(HideCursor) preset at runtime that it works as intended :( Switching states doesn't make the aim assist work correctly 100% of the time.

It used to work just fine :(
 
Last edited:
Some additional information that I hope will help solve what I have done wrong.

Aim assist won't recognise a target unless I set the collision raduis to around 10 at the least. It will then locate a target, but it will keep losing then gaining the target.
 
If you debug the CrosshairsMonitor.Update method is the target going in and out? The spherecast radius of 10 is extremely large so it almost sounds like your crosshairs is in the wrong location from where you expect it to be. In the next version I'll add a debug output so you can see the crosshairs ray being drawn (I should be able to release this version next week).
 
Thank you, Justin how would I go about reseting the location of the CrosshairsMonitor?
 
I have been trying to resolve the issue but now I am just getting a null reference issue :(

NullReferenceException: Object reference not set to an instance of an object Opsive.UltimateCharacterController.UI.CrosshairsMonitor.Update () (at Assets/Opsive/UltimateCharacterController/Scripts/UI/CrosshairsMonitor.cs:166)

Line 166 is

var crosshairsRay = m_Camera.ScreenPointToRay(m_CenterRectTransform.position);
 
Last edited:
So the null reference doesn't happen if I enable the crosshairs game object at runtime - is that how it is supposed to work? I am also still facing the lock on issues :(

It seems that using a screen space camera is causing me the issue.

As I am using heavy post processing I opted to use a second camera for the UI with the canvas being set up as screen space.
 
Last edited:
If I can get rid of this null reference issue, I should be able to get everything working :)
 
If I create a clone at run time of the demo canvas - I don't get a null reference, but If I put the demo canvas in my scene and run the game then I will get the null reference - I hope you can help me out.
 
Last edited:
I think that what will be easiest for us to debug is if you tell us how to reproduce it within the demo scene. Are you also using the latest version? Line 166 is different in the latest version.
 
I didn't upgrade - as I am using it for a wolf I didn't really need all the improvements that you made to the controller. I will take a look into reproducing the issue in the demo scene - there must be some conflict if the demo scene still starts up ok.

The demo scene works as expected - it must be something in my scene causing the issue :(
 
I tried to upgrade to the latest version and I had more errors than before. Could you please advise the best way to find out what is causing the null reference.

I haven't changed anything in the script and it works in the Demo scene with no issues.
 
Do you have a center crosshairs image assigned? Right now the CrosshairsMonitor requires a sprite in order to completely initialize. I will change it in the next version so it can work without needing a sprite.
 
Hi Justin,

I have made a script to create a clone at run time of the Crosshairs gameobject - I don't get the error if the crosshairs is created a runtime. Everything was set up correctly - it is really weird.

The aim assist requires a canvas of type screen overlay - I am using screen space camera, that was causing the jittery lock on issue. I created a seperate canvas to use just for aim assist and it targets as you created it too :)
 
Top