Hello,
you might of saw my posts about platformers, etc, well I’m going to tell you how to get started on your own Platformer!
Step 1
Biography about Body Velocities.
If you know about body velocities they can make things move just like this:
All you have to do to make a part move is insert a body velocity and click run:
This could be sped up.
These Body Velocities can be added to the player too.
Here is an example for a bare-bones fly script.
--Local script in statercharacterscripts
local c = script.Parent
local V =Instance.new("BodyVelocity", c.HumanoidRootPart)
V.Velocity = c.HumanoidRootPart.CFrame.LookVector * 10
Here is the script.
Next we will be learning about look vectors!
Step 2
Learning About Look Vectors
Lets start by putting a empty local script in StarterCharacterScripts and name it “LookVectorTest”
First we will get the players input by using “UserInputService”
local UIS = game:GetService("UserInputService")
local c = script.Parent
UIS.InputBegan:Connect(function(key)
if key.KeyCode == Enum.KeyCode.E then
--Function
end
end)
Alright, next create a new function, I’m going to name it “VelocityFunction”
local UIS = game:GetService("UserInputService")
local c = script.Parent
function VelocityFunction()
--The script
end
UIS.InputBegan:Connect(function(key)
if key.KeyCode == Enum.KeyCode.E then
VelocityFunction()
end
end)
Next I am going to add a velocity to the player.
Add this inside the function:
local V = Instance.new("BodyVelocity", c.HumanoidRootPart)
V.MaxForce = Vector3.new(math.huge,0,math.huge)
V.Velocity = c.HumanoidRootPart.CFrame.LookVector * 100
wait(.2)
V:Destroy()
Your final script should look like this.
local UIS = game:GetService("UserInputService")
local c = script.Parent
function VelocityFunction()
local V = Instance.new("BodyVelocity", c.HumanoidRootPart)
V.MaxForce = Vector3.new(math.huge,0,math.huge)
V.Velocity = c.HumanoidRootPart.CFrame.LookVector * 100
wait(.2)
V:Destroy()
end
UIS.InputBegan:Connect(function(key)
if key.KeyCode == Enum.KeyCode.E then
VelocityFunction()
end
end)
By pressing E you should preform some sort of dash move.
If you are seeing how the player dashes where the player is facing it is does with this line
V.Velocity = c.HumanoidRootPart.CFrame.LookVector * 100
Look Vectors are helpful in making platformers, they detect which way an object is facing.
Step 3
Advancing in Animations
Now, I’m not the best animator, but I’ll at least try.
If you play around with animation editor you can make something to your liking.
Example:
Now place the animation you made in ReplicatedStorage.
Add this line of code in the function and you will be ready to go!
c.Humanoid:LoadAnimation(game.ReplicatedStorage.PlayerAnim):Play()
Step 4
Digging Deeper into Debounce
If you didn’t notice if you spam the key E it will act all weird.
You can fix this easily with 3 lines of code.
local canBoost = true
local UIS = game:GetService("UserInputService")
local c = script.Parent
function VelocityFunction()
if canBoost then
canBoost = false
local V = Instance.new("BodyVelocity", c.HumanoidRootPart)
V.MaxForce = Vector3.new(math.huge,0,math.huge)
V.Velocity = c.HumanoidRootPart.CFrame.LookVector * 100
c.Humanoid:LoadAnimation(game.ReplicatedStorage.PlayerAnim):Play()
wait(.2)
V:Destroy()
canBoost= true
end
end
UIS.InputBegan:Connect(function(key)
if key.KeyCode == Enum.KeyCode.E then
VelocityFunction()
end
end)
Yeah uh, that’s it for this section…
Step 5
Particles, yes… just particles ;-;
You can add any particle you want just make it emit from the back.
Now put your particle in ReplicatedStorage.
Again to add them just put 3 lines of code
Note
Make sure if your rig is R6 set it to “Torso” instead of “LowerTorso”
local canBoost = true
local UIS = game:GetService("UserInputService")
local c = script.Parent
function VelocityFunction()
if canBoost then
canBoost = false
local particles = game.ReplicatedStorage.Smoke:Clone() -- your particle name
particles.Parent = c.LowerTorso
local V = Instance.new("BodyVelocity", c.HumanoidRootPart)
V.MaxForce = Vector3.new(math.huge,0,math.huge)
V.Velocity = c.HumanoidRootPart.CFrame.LookVector * 100
c.Humanoid:LoadAnimation(game.ReplicatedStorage.PlayerAnim):Play()
wait(.2)
V:Destroy()
particles:Destroy()
canBoost= true
end
end
UIS.InputBegan:Connect(function(key)
if key.KeyCode == Enum.KeyCode.E then
VelocityFunction()
end
end)
As you can see it emits the particles.
Final
Final
I am going to add some final touches, I am not going to say much just fixing bugs
Here is the final script!
local canBoost = true
local UIS = game:GetService("UserInputService")
local c = script.Parent
function VelocityFunction()
if canBoost and c.Humanoid.MoveDirection ~= Vector3.new(0,0,0) then
canBoost = false
local particles = game.ReplicatedStorage.Smoke:Clone() -- your particle name
particles.Parent = c.LowerTorso
local V = Instance.new("BodyVelocity", c.HumanoidRootPart)
V.MaxForce = Vector3.new(math.huge,0,math.huge)
V.Velocity = c.HumanoidRootPart.CFrame.LookVector * 100
c.Humanoid:LoadAnimation(game.ReplicatedStorage.PlayerAnim):Play()
c.Humanoid.AutoRotate = false
game.ReplicatedStorage.Boost:Play()
wait(.2)
V:Destroy()
particles:Destroy()
canBoost= true
c.Humanoid.AutoRotate = true
end
end
UIS.InputBegan:Connect(function(key)
if key.KeyCode == Enum.KeyCode.E then
VelocityFunction()
end
end)
Make sure to put a sound called “Boost” in Replicated Storage.
Thanks for reading!
- Yes
- No
0 voters
https://www.roblox.com/games/6821976860/Platformer-Testing-Uncopylocked
Here’s the place link
You will have to make your own animations.
Feedback is appreciated, including criticism
For the people who skipped through the whole thing:
Mission Passed
Respect+