Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
3

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

Asked by 9 years ago

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

Log in to vote
0
Answered by
Goulstem 8144 Badge of Merit Moderation Voter Administrator Community Moderator
9 years ago

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
0
I get your logic, but it didn't work. It made my character spin around unpredictably, and way too powerfully. ZeptixBlade 215 — 9y
0
I tested it in studio and it worked perfectly for me(maybe a bit fast but you can change that easily) Goulstem 8144 — 9y
0
I think i need a new method. The direction of the rotation changes, even the speed changes, between tests. ZeptixBlade 215 — 9y
Ad

Answer this question