Fixing BodyGyro/BodyAngularVelocity Issues?
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.
01 | local sling = script.Parent |
02 | local start = sling.Start |
03 | local midpt 1 = sling.MidPt 1 |
07 | start.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" ) |
12 | local Rocket = Instance.new( "RocketPropulsion" , plr.Parent.Torso) |
13 | local Gyro = Instance.new( "BodyGyro" , plr.Parent.Torso) |
14 | local AngularV = Instance.new( "BodyAngularVelocity" , plr.Parent.Torso) Creates BodyAngularVelocity |
15 | Gyro.CFrame = CFrame.new(plr.Parent.Torso.CFrame:vectorToWorldSpace(Vector 3. new( 1 , 0 , 0 )), midpt 1. Position) |
16 | Rocket.Target = midpt 1 |
17 | Rocket.CartoonFactor = 1 |
18 | Rocket.TargetRadius = 1 |
19 | Rocket.MaxThrust = 10000 |
22 | Rocket.ThrustP = 100000 |
24 | AngularV.AngularVelocity = player.Torso.CFrame:vectorToWorldSpace(Vector 3. new( 0 , 1 , 0 ))* math.rad( 360 ) |
25 | AngularV.MaxTorque = Vector 3. new( 9000000 , 9000000 , 9000000 ) |
26 | humanoid.PlatformStand = true |
28 | Rocket.ReachedTarget:connect( function () |
29 | local Position = Instance.new( "BodyPosition" ,plr.Parent.Torso) |
30 | Position.Position = fin.Position |
32 | Rocket.ThrustD = 100000 |
33 | Position.ReachedTarget:connect( function () |
38 | humanoid.PlatformStand = false |
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