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

Fixing BodyGyro/BodyAngularVelocity Issues?

Asked by 9 years ago

I'm trying to create a rough outline of point to point "flight" in a Super Mario Galaxy-esque way. For those of you unfamiliar with the games, the main method of transportation between two points is using a "Launch Star" which shoots you from point A to point B in a cool looking fashion as shown here https://gyazo.com/063ce47111186adf379adf69b23920db

I want to recreate that flight path using a (most likely bigger than necessary) collection of BodyMovers. So far I have the flight path down to a degree using Rocket Propulsion and a BodyPosition (Solely for the "Reached Target" event as the Rocket Propulsion one seems to only fire once)

As you may have noticed in the gif, the top of the player's head faces their direction of flight and spins across an axis drawn from their head to their toe (Object's Y Axis)

My issues lie with making my BodyGyro objects have the head/top of torso face it's destination and having the BodyAngularVelocity rotate around the local Y Axis. I'll label the problem lines below the full scope to make it clearer.

01local sling = script.Parent
02local start = sling.Start
03local midpt1 = sling.MidPt1
04local fin = sling.Fin
05local IsLaunch = false --Debounce
06 
07start.Touched:connect(function(plr)
08    if plr and plr.Parent and plr.Parent:FindFirstChild("Humanoid")and not IsLaunch then
09        local player = plr.Parent
10        local humanoid = plr.Parent:FindFirstChild("Humanoid")
11        IsLaunch = true
12        local Rocket = Instance.new("RocketPropulsion", plr.Parent.Torso) --Creates RocketPropulsion
13        local Gyro = Instance.new("BodyGyro", plr.Parent.Torso) --Creates BodyGyro
14        local AngularV = Instance.new("BodyAngularVelocity", plr.Parent.Torso) Creates BodyAngularVelocity
15        Gyro.CFrame = CFrame.new(plr.Parent.Torso.CFrame:vectorToWorldSpace(Vector3.new(1,0,0)), midpt1.Position) --Failed Attempt #1
View all 43 lines...

First off, my BodyGyro issue lies on Line 15 Gyro.CFrame = CFrame.new(plr.Parent.Torso.CFrame:vectorToWorldSpace(Vector3.new(1,0,0)), midpt1.Position) where I attempt to have the top of the torso pointed at the target midpt1

My second issue with the BodyAngular Velocity Lies on Line 24 AngularV.AngularVelocity = player.Torso.CFrame:vectorToWorldSpace(Vector3.new(0,1,0))* math.rad(360) where I attempt to have a constant rotation around the Player's Y Axis to simulate the smooth barrel rolls done in the gif shown above.

The 3D representation of the path from Green to Blue ending at Red: https://gyazo.com/e9290ddbc64d8916871a62b7b49e20b6

The Heiarchy: https://gyazo.com/e134c17cd1c06bda33ce6db129ae7e05

Thank you for any help given and for reading through this lengthy question! This is information useful to me now, and it will be useful to me forever. If only they taught CFrames in Algebra II/Trig

~MBacon15

0
Very detailed question. User#11440 120 — 9y
0
I look at the "failed" and rejected questions for inspiration. I try to be sure to include absolutely everything that could be asked, and break it down MBacon15 97 — 9y
0
tldr UniversalDreams 205 — 9y
0
The TL;DR is right below the code block MBacon15 97 — 9y

Answer this question