Top down Aim Offset is not going where it should.

Hey all, this is probably a question regarding vector math that I don’t fully understand so any help figuring this out would be appreciated.

I’m working on a top down prototype for fun at the moment where I need to characters spine rotate based on an TransformModifyBone node in the ABP, got all that set up to be working I think, but having issues actually calculating exactly where the Aim Offset should actually be.

This is the way I’m trying to do it basically have the Actor look up and down based on where the Cursor Hit Result is. However the result on the spine rotation is way above the actual intended location and goes further up the further away the cursors impact point is.

Aim Offset

Here’s the shooting linetrace logic aswell.

And the Transform(Modify)Bone stuff just incase.

you line trace is just ‘ending’ in ForwardDirection of the Muzzle not where the MouseHits.

so just save the MouseImpactPoint and use that as the LineTrace EndPoint, or recalculate the UnitDirection from the Muzzle.

Ending the trace at cursor hit result gives the ability to shoot behind the player if the player moves the mouse quick enough, which is no beuno. So I’m basically rotating the player towards the mouse location elsewhere and then trying to rotate the spine rotation to make the spine rotate towards the mouse cursors Z location. However I think it could also be a possibility that the actual animation of holding the rifle isn’t actually straight forward but might be slightly tilted upwards, so its like I’m trying to compare the barrels forward with the actual mouse hit location if that makes any sense.

However I made so that the actor shoots towards the hit result from the cursor if its facing that direction otherwise its going to select the forward vector from the muzzle rotation instead.

It looks kind of weird and iffy but could possibly be fixed whenever or if I ever get other animations that isn’t pointing slightly up. I’m happy as long as it works for now.

yeah you’re only modifying spine1 so thing like aim/eye offsets would be different.

your approach is correct, cache the ‘Target’ and recalculate when you fire.

keep in mind even the mousehitresult can be slightly off, for instance your line trace could end 1pixel short and result as a miss. depending on your game it might be better to cache a target Actor and then use GetActorLocation as a target vector