AlignOrientation: Secondary Axis only?

Hello!

I’m currently building a system for picking items and weapons up in VR.
To prevent weapons from phasing through walls, I use a physics based system using AlignPosition and AlignOrientation. When the user picks up the grip of the gun, an AlignPosition and AlignOrientation get created to make the gun follow the user’s hand (with one attachment being in the player’s hand and the other being in the grip). When the handguard gets grabbed as well, a second AlignPosition is created (with attachment 1 being in the handguard and 2 being the player’s hand) to make the gun align with the 2 hands. However, this causes issues.

The AlignOrientation conflicts with the second AlignPosition, as the AlignOrientation tries to make the gun point to the direction of the hand on the grip, and the (second) AlignPosition tries to make the weapon align with the 2 hands. Disabling the AlignOrientation is also not an option as it makes the weapon dangle on the 2 hands (because of the bodypositions) (see gif below). Since the primary axis is the one pointing forward, it’s the one being used to make the weapon align with the direction of the hand on the grip. The secondary axis is the one preventing it from dangling, so the PrimaryAxisOnly property also isn’t a solution. Something which would fix it is an AlignOrientation with a SecondaryAxisOnly property. How could I achieve something like this using scripts without having to mess with the Attachments’ orientations / axes? Thanks!

The AlignOrientation and AlignPosition conflicting:
ezgif.com-gif-maker (19)

Solution 1, disabling the AlignOrientation when grabbing the handguard:
Disabling

Solution 2, using PrimaryAxisOnly
ezgif.com-gif-maker (18)

Swap the primary and secondary axes of whatever attachment the AlignOrientation is acting on and use PrimaryAxisOnly. If other objects depend on the attachment having the current axes, make a copy of the attachment and use that for the AlignOrientation.

1 Like

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