I am attempting to make a jetpack, however it is not one of those “where your camera looks it goes” jetpack. I am trying to make a jetpack that would always (if activated) go up in a angle. The camera would still be used to dictate which way the player would go, but not the angle.
I currently do not know how to achieve this goal. I only want the jetpack (if activated) to contanstly lift the players on a 120 angle. And the player could change the directions of where he is going (obviously) with his camera. I do not know how to combine these two things.
I went through many roblox tools, even on the catalog section. However all of them are those type of jetpacks that will basically let you fly in any direction and on any angle. I do not want this.
You’ll probably want to take a look at VectorForce or experiment around with them. If you deconstruct the problem and look at the goal (making players glide upwards), I’m sure this could help you quite a bit.
In terms of utilising the VectorForce, I would assume that you want something relative to the player’s position. You’ll then want to send them up along the forward and up axis (can’t remember what those are - X and Z?).
Alright so assuming you mean 60 degrees up relative to the front of the character (120 degrees would be flying backwards and up), we can accomplish this with a little math.
The equation for this would be a Unit vector of the direction * a specific force. To get the Unit vector you can use: Vector3.new(0,math.sin(math.rad(60)),-math.cos(math.rad(60))).Unit with 60 being the desired angle. Now multiply this by a specific Force and apply it into a VectorForce in the characters HumanoidRootPart.
Here’s the code I used in a LocalScript under StarterPlayerScripts:
local Character = Player.Character or Player.CharacterAdded:Wait()
local HRP = Character:WaitForChild("HumanoidRootPart")
local Force = 3500
local VectorForce = Instance.new("VectorForce",HRP)
local Attachment = Instance.new("Attachment",HRP)
VectorForce.Attachment0 = Attachment
wait(3)
VectorForce.Force = Vector3.new(0,math.sin(math.rad(60)),-math.cos(math.rad(60))).Unit*Force
Let me know if you have any more questions about this
Another question, how would I make the force constant. At the moment it is like the player is jumping just really high and eventually gravity pulls him down. I want the player to constantly be moving on the angle scale until the script tells the player to stop.