2D Aim Offset on the edges

Hello I was wondering if anyone know if it is possible to make a 2D Aim Offset play the animation on the edges only and ignore the middle of the graph, I am making a side scroller
game where the player aim his weapon as shown.

ezgif-1-eb167b52b8

I am trying to stop this from happening

ezgif-1-ea17c0fe73

I would suggest using a 1D Aim Offset instead of 2D, with the horizontal axis min/max set to -180 through 180, and 0 aiming straight up. +90 would then be aim forward pose,-90 is aim backward pose, then -180 and 0 are aiming straight down pose.

The math for setting the var depends on which plane you’re locking movement to. For me, “north” in editor is screen right and “south” is left, with the camera always pointed “west.” The math in my character blueprint looks like this:

Teh aimtarget var there is the world location of the mouse or a location offset generated by joystick input for the player, or the focus target location for NPCs.

The +40 to z on that first get actor location is to move the the start up from center of capsule to roughly the shoulder line.

1 Like

Thanks for the suggestion. I will try it and see if it works with me

Here’s a capture of how the aim offset asset looks:

The aimdir var in code sample above feeds the AimAt axis for the offset.

1 Like

I implement it And it worked like magic thanks a lot,

here is how I implement it with the controller axis input


“side note” you need to make the 180 pose and 180- pose the same Pose to prevent it from warping, here is an example of it having the same pose and not having the same pose

having the same pose
notwriping

not having the same pose

wriping

Glad it worked for you!

I probably should have mentioned it above, but as for the warping, yea, using a similar pose in ±180 is needed. Also helps to tick the “wrap input” option in the aim offset. Doesn’t look like it’s a problem for you, but my characters’ heads spin around like a cartoon owl when passing the 180 mark. If you run into that later with a different weapon, I think the fix is to make the -180 pose slightly different so the rotation delta is smaller when the head turns in the proper direction.

Also, if you (or anyone else who finds the topic later) want to add mouse aim to the mix, here’s my spaghetti noodles for aim input:

As per the code sample further upstream, I use world location of a target for the offset calculation so it will work with mouse, gamepad, or a simple target actor location variable on npcs.

The math on the LinePlaneIntersect node for mouse aim input will depend on which plane movement is locked to. In my case, actors are constrained to Y/Z plane at 100 x. I use 100 instead of 0 to minimize navmesh triangles, since a centered navmesh will split the cells in half along 0 in the x and y axis for some reason.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.