Download

Gun Sight Aligner

if our game already has aim mechanics replicated, would adding this be as simple as plug n play? After migrating the asset

No, in any case it’s not as simple as plug n play. You will have to integrate anyway.

Seems like I skipped your post, my bad.

If I understood it correctly, your “end” bone is where the hand bone would normally be, so your skeleton is:

arm->forearm->end
which is the same as

arm->forearm->hand
(Epic’s skeleton, just with different names)

So if you’re attaching the gun to the “end” bone (or to a socket on the “end” bone) and replacing the references to “hand_r” with references to “end” in the code, then alignment should be working normally. This way, the “end” bone would already be the IK effector, and that is enough, yes. (Unless I didn’t understand your setup)

In my test the IK worked from hand to forearm, while the upperarm would keep in place. It looked fine, but the gun wouldn’t get to it’s place in front of the camera, because with only hand and forearm moving, it doesn’t have enough reach. That’s why I’m saying it wasn’t a problem with the IK, it was working like it’s supposed to, it was a skeleton problem…

Hi yeah its a skeleton problem. I originally thought it couldn’t be right because of the way its not working. it (presumably) can reach, its just flying off behind the camera. I went in “game” to take another look, and i noticed it looked like its moving around the sight VB. I tried thinking of what was wrong with it, and somehow remembered your mixup with arms only and full body. So I thought the ABP instructions might be for full body. So i looked in both mannequin skeletons, and the sight VB is attached to the head on full body, and the root bone on arms only. So i redid the VB to the root bone and sure enough, it works now (although some sights are tilted a little which is weird but ok).

So yeah, you need to change the instructions on the arms ABP to say to attach the sight VB to the root.

I wish i noticed earlier, thanks for tryna help, i wouldnt have noticed if it werent for this so yeah, thanks

And now, we have a final thank you count… of 7. I had a joke to go here biut i forgot it oops

Thank you for this, it makes perfect sense. In my head I had thought about making VB sight a child of the root in the arms-only skeleton (to avoid problems like this), but I didn’t remember actually doing it. I will update the instructions in v2.0.3, since v2.0.2 is aleady out.

I’ll try to find out what could be causing your sights to be a little tilted.

Thank you!

Updated to 2.0.2

Change log:

  • 3rd person camera moved a little to the side, so the character isn’t exactly in the center of the screen anymore

  • Quick fix: the variable CycleSightsSpeed is now wired to the interpolation (Ease node) in the character’s anim blueprint. So now changing the gun blueprint’s own variable CycleSightsSpeed will customize the speed of switching sights while aiming, as it’s supposed to.

Updated to 2.0.3

Change log:

  • Quick fix: instructions for setting up virtual bones in a custom skeleton, written in the anim graph of the arms-only anim blueprint - fixed.

Updated to v2.0.4:

Chang log:

  • Reorganized code and comments with integration in mind. It now should be easier to visualize what events should go where, when integrating with other projects.

Hey there, bit of a problem after converting to alsv4’s skeleton…

I added all the correct virtual bones, i added the fullbody animbp as a linked overlay layer in als’ animbp, replaced all references to point to the correct linked layer. then reparented the b_character_fullbody as a child of als’ anim man…

Now i get a problem where the gun does not go into ads, just holds the base idle pose. but when aim is activated, the right hand snaps to the head and aims backwards.

Ideas? or more information you can point towards changing the character?

@thelazylion

The character in the 1st image you sent doesn’t seem to be in-game, it looks like he’s in the viewport of the anim BP or the anim viewer. Only when he is in-game, and with the gun in his hands, the positions of the gun sights are calculated (CalcSightsTransforms) and sent to the anim BP. If I look at my character aiming in the anim BP viewport, I get a similar result to yours:

So don’t forget to bring CalcSightsTransforms to your gun BP (and call it when the gun is attached to your character’s hand) and test your character in-game. If you’re getting similar results in-game, there could be something missing in the CalcSightsTransforms implementation.

I haven’t tried yet to apply the Gun Sight Aligner to the ALS character (will probably try it when I have some time), but I believe it should be possible.

That screen shot is of the anim bp, but Ingame.

There is a preview feature for debugging, while the game running in editor, you can select from a drop down at the top, a list of active anim BPs being used in the world… and it’ll mimic what is playing in game.

So yeah it does the same in game…

I’ll look until the calc sights implimentation, thanks for the heads up on that.

I just reparented the class over the als one. So I assume it’s in the the anim bp I missed.

CalcSightsTransforms is in the gun bp, it needs to be in your gun bp (or your gun bp’s parent class) and be called after the gun is attached to the character’s hand. The Gun Sight Aligner’s example character attaches the gun and calls its CalcSightsTransforms at EventBeginPlay. CalcSightsTransforms contains a ref to the hand bone - hand_r - and if your bone has a different name, you need to change the ref to match your own bone name, although I think the ALS character’s hand bone name is also hand_r.

Not sure whats wrong then, since I’m using the same example classes. I just parented the character under the als character, setup the anim bp and virtual bones, and the screenshot was the result…
and yeah bone names are pretty much the standard.

@thelazylion:

Check if:

  1. ClacSightsTransforms is actually producing transforms: After attaching the gun to the hand, use a PrintString node to print the length and values of the SightTransforms array, which is filled by CalcSightsTranforms. Length of 0 means that CalcSightTransforms isn’t working (or the gun has no tags or aimpoint sockets). Note: the Aim event of the product already includes a check to prevent trying to aim when this array is 0, but your character is already aiming in your pic, which tells me your array length isn’t 0.

  2. The anim BP is actually receiving and using some value of this array: Use PrintString nodes in the anim BP to check the RelativeToHandLocation and RelativeToHandRotation values. They must be the same as the values in the SightTransforms array.

thanks for the info, looks super useful. I’ll get back to you with any updates…

Thx again

Still happening., removing and re adding to project seemed to work with the default anim bp, even using the alsv4 skeleton/mesh. However I think due to a natural 2-3 degree offset in Alsv4’s system, the aim is off by about a few degrees when ads’ing by default. This isn’t too much of an issue. I’m just adding a 2-3 degree offset on any optical sight. Or maybe I’ll just add a base offset at the end of the animbp…

The issue is when the animbp is replaced with alsv4’s animbp and everything is copy pasted over, including events, and references to the animbp are changed, the aim always just reverts to 0,0,0 on his head.

Even though calc sight transform is printing a decent offset in the anim bp, i attached the calc sight on aim as well just to make sure, however still the same results as posted above.
[Edit on the above]: Seems a macro didnt get copied over for the sight transform in animbp…

Thanks again for the help…

Another, quick (or possibly not) question while I move onto the next module of the project.
If I want to set the mesh as the root, instead of the scene, what would be the correct process of doing this with the least amount of unnecessary overhead?

Thanks again in advanced…

Would it be possible to add a tutorial on how to integrate everything properly in ALS? It would be super helpful, thank you :smiley:

In your gun bp, in the “Components” panel (the one on the top left corner where you see your components hierarchy), just drag the mesh on top of the DefaultSceneRoot, and it will become the root automatically.

Now about your issue, it’s been resolved if I understand correctly?

I need to try and integrate it with ALS on my end first, to see what issues might come up. When I have the time I’ll try it and, depending of how it goes, I’ll make a guide…

yes, it was a lot of work and to be honest I don’t remember what I did exactly. But I had to add an offset to the calcsights transform in the anim bp to account for the als offset…

Pistols are perfect however rifles that use optic aim are still not centered perfectly. I will keep tinkering