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

How do I make a BodyAngularVelocity apply force relative to the Part it's in?

Reposting this since my original post got ignored and is now 5 pages down.


I'm trying to use a BodyAngularVelocity to continually make a character flip over backwards. Unfortunately, instead of flipping over backwards, my character just flips towards the global x direction. The direction should change based on which way the character is facing, but it always goes towards global x.

Yes, there are things that would make this code glitchy. They're not a problem, I'm just disabling and enabling the script. I'll fix them after I get the main part working.

--LocalScript, no output.
local plr = game.Players.LocalPlayer
local chr = plr.Character
local bav = Instance.new("BodyAngularVelocity",chr.Torso)
bav.maxTorque = Vector3.new(1000,1000,1000)*999
bav.P = 9999
bav.angularvelocity = Vector3.new(2,0,0) * math.rad(360)

1 answer

To rotate relative to the character, you have to set the angularvelocity relative to the player.

local plr = game.Players.LocalPlayer
local chr = plr.Character
local bav = Instance.new("BodyAngularVelocity",chr.Torso)
bav.maxTorque = Vector3.new(1000,1000,1000)*999
bav.P = 9999
bav.angularvelocity = (chr.Torso.CFrame * CFrame.new(2,0,0)).p

3 comments

0

I get your logic, but it didn't work. It made my character spin around unpredictably, and way too powerfully.

0

I tested it in studio and it worked perfectly for me(maybe a bit fast but you can change that easily)

0

I think i need a new method. The direction of the rotation changes, even the speed changes, between tests.

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