Help with CFrame/Vector3 math (Ball Controller)

  1. What do you want to achieve?

I’m currently turning the player into a sphere and would like to make the sphere move based off VectorForces.

  1. What is the issue?

The VectorForce is attached to an attachment within the sphere. When giving the sphere force, it starts to rotate (as a sphere should), but that also makes the attachment, which is relative to the sphere, rotate as well. I need the attachment’s .Orientation property to act as a gyroscope that always keeps the attachment level.

  1. What solutions have you tried so far?

I’ve looked for solutions. Couldn’t find any, unless I’m searching for the wrong subject.

My own personal solution currently is to counter-act the sphere’s .Orientation property ~ if the sphere’s x axis is 95, the attachments .Orientation is set to 95 on the x axis as well (Keep in mind that attachments orientation does not change whilst the ball is rolling as its relative to the ball. It will stay at 0,0,0 unless the value is manually changed), which negates the rotation of the ball, but the problem is that only works on a 2 dimensonal plane. Once the third dimension is involved, you can’t just negate values and expect it to work. That’s where I am at a road-block, and hope that a math wiz can help me.

ballControllerLQ
Above: The attachment making sure it rotates to counter-act the balls rotation, but when it’s moved off 1 axis it doesn’t work anymore.

1 Like

Have you tried editing the RelativeTo property for vectorforce

1 Like

Tried it, the only problem I have then is figuring out how to apply force to where the camera is looking.

The current way I was working to do it is have the attachment’s Orientation.Y point in the direction opposite of the camera, which makes sure that when I apply a force on the VectorForce to the Y axis, it will always be straight, where the player is looking.

This isn’t direct help, but here’s a really cool resource for how cross products work. Unity Vector3.Cross Visualized - YouTube

1 Like

Wait, I think I found the solution after looking back on it making it relative to Attachment1, instead of Attachment0.

If I make a part that’s CFrame is equal to the players camera, and then add an attachment inside of it, it works how I would want it to.

Now I just need to make it only work on the Y axis, and I have a makeshift solution.

If anyone has a better and less resource-heavy way of solving this issue, let me know. Thanks guys and gals!

boulderFixedLQ

Checkout this function using VectorToWorldSpace

1 Like

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