Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

BodyAngularVelocity + lookVector - The Axis that a sphere rotates?

Good afternoon everyone so basically I have a script where you kick a ball, and the ball spins.

Unfortunately, the ball spins in the wrong direction. It spins horizontally. If you have ever see a ball backspin in real life, I need to make it like that.

This is the section of the code that is spinning the ball horizontally:

G.AngularVelocity = RL.CFrame.lookVector * -80

G.MaxTorque = Vector3.new(0,40000,0)

G.P = 20000

But I'm pretty sure it has something to specifically do with this line:

G.AngularVelocity = RL.CFrame.lookVector * -80

I've tried the roblox scripters forum but they do not know. If you can help me, I will greatly appreciate it. Thanks.

2 comments

0

Try changing the values of the MaxTorque property as your ball could be spinning on the wrong axis.

0

It has to be (0,40000,0) because otherwise, if the ball landed the spin would cause the ball to move left/right. It has to backspin in a straight line. Thank you for your response though.

1 answer

Hello, Sorry if this is a late response. I may have been just having a similar problem (which I just fixed) that you may have been having as well. I noticed two errors in your code.

  1. When multiplying a Vector3 (in your case it's a lookVector) by a value, that value is always in radians, and that radian measure is how much the item that contains the BodyAngularVelocity will rotate per second. For example, if you wrote: G.AngularVelocity = Vector3.new(0, 1, 0) * math.pi --math.pi is equal to 180 degrees in radians then the item would rotate 180 degrees per second. To convert degrees to radians (I'm assuming you would like -80 degrees), you would write math.rad(-80). "math.rad" converts degrees into radians. So change wherever the "-80" is in your code to math.rad(-80).

  2. You are rotating on the wrong axis. To make the ball rotate upwards, you must rotate on the X axis. Imagine the axis is a rod which the ball is rotating around. If the rod is horizontal, the ball will rotate upwards. The X Axis equivalent to lookVector is rightVector. You also need to change the MaxTorque to Vector3.new(40000, 0, 0) (if you don't want specifically 40000, just use math.huge, which creates just a very large number).

So, your updated code should look like:

G.AngularVelocity = RL.CFrame.rightVector * math.rad(-80)
G.MaxTorque = Vector3.new(40000, 0, 0)
G.P = 20000

If you need any more clarification or help, just comment.

This discussion is preserved as it was. New answers, comments, and votes are closed.