# Need help with cross product application

Currently I’m developing jet skis and one of the issues that I am running into is that when I try to align the jet ski with whatever surface it’s hitting on the bottom I’m getting different results based on the rotation of the surface I’m hitting.

In the gif below, the wedge has a rotation of about 180 degrees, and as you can see the jet ski is able to align itself properly.

https://gyazo.com/4c4393234e508ecc4f00665c30e5f7a9

However, if I rotate the wedge to about 90 degrees the jet ski doesn’t align properly.

https://gyazo.com/25f808109f93a162ac5da85bfe2328c7

To align the jet ski I’m simply ray casting from the front of the jet ski and crossing the normal that is returned with Vector3.new(0,1,0) and setting the CFrame of the AlignOrientation using CFrame.fromAxisAngle to align the jet ski.

Any help would be appreciated, thank you!

1 Like

Have you tried PrimaryAxisOnly?

I have not, because I’m using the AlignOrientation to keep the jet ski from tipping over, and I am using it to rotate the jet ski. Which requires the use of both Axes.

Can you post the AxisAngle constructor you’re using?
Also which direction of the jetski is the Z-Axis, which the Y-Axis and which the X-Axis?

The directional values are decided by an attachment that I have placed infront of the jetski.

https://gyazo.com/706022071a1b355cc46b9a05c95b7f5e

As for the AxisAngle constructor what I’m doing is;

Aligner.CFrame = CFrame.new(jetski.Position) * CFrame.fromAxisAngle(rotAxis,rot) * CFrame.Angles(0,XROT,0)

XROT = Rotation of the jetski on the Y Axis (side to side rotation based on Steer value)

Kinda stumped.
How does it look with other angles other than 90 and 180 degrees, is there any pattern recognizeable?
Also it checks more than once right? So as the Jetski turns due to the aligning the value of XROT also changes?

Yes it checks more than once. XRot changes based on user input, however, it does not change due to the aligning value.

Edit: As for any patterns, I can’t see any x_x.

Problem is solved. Thanks to EgoMoose’s open sourced code!

I should start marking my own posts as answers too.

I honestly don’t know how to mark it as solved otherwise lol, unless you can clue me in ;)?

Could you include a link to this supposed open-source code so other readers looking at your thread with a similar problem know where to look?

2 Likes

Of course. CharacterTilt.rbxl (14.6 KB)

1 Like