Hello, I tried making a vaulting system, I suceeded in detecting WHEN the player should vault but I have some problems on coding the vaulting, I dont know how to make the player actually move through the part the are vaulting to.
local UIS = game:GetService("UserInputService")
local player = game.Players.LocalPlayer
local char = script.Parent
iswalking = false
local function findPartInFrontTorso()
local rayParams = RaycastParams.new()
rayParams.FilterType = Enum.RaycastFilterType.Exclude
rayParams.FilterDescendantsInstances = {char}
local origin = char["HumanoidRootPart"].Position
local direction = char["HumanoidRootPart"].CFrame.LookVector
local rayLength = 1
local result = game.Workspace:Raycast(origin, direction * rayLength, rayParams)
if result then
return result.Instance
end
return nil
end
local function findPartInFront()
local rayParams = RaycastParams.new()
rayParams.FilterType = Enum.RaycastFilterType.Exclude
rayParams.FilterDescendantsInstances = {char}
local origin = (char["Left Leg"].Position + char["Right Leg"].Position)/2
local direction = char["Right Leg"].CFrame.LookVector
local rayLength = 1
local result = game.Workspace:Raycast(origin, direction * rayLength, rayParams)
if result then
return result.Instance
end
return findPartInFrontTorso()
end
UIS.InputBegan:Connect(function(i, g)
if not g and i.KeyCode == Enum.KeyCode.Space and iswalking == true and findPartInFront() then
local part = findPartInFront()
local playerHeadPosition = char:FindFirstChild("Torso").Position.Y
local wallTopPosition = part.Position + part.Size/2
if playerHeadPosition and wallTopPosition then
if playerHeadPosition >= wallTopPosition.Y then
VAULTING CODE HERE!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
end
end
end
end)
UIS.InputBegan:Connect(function(i, g)
if not g and i.KeyCode == Enum.KeyCode.W then
iswalking = true
end
end)
UIS.InputEnded:Connect(function(i, g)
if not g and i.KeyCode == Enum.KeyCode.W then
iswalking = false
end
end)
Create an animation that resembles a player vaulting an object. Then play the animation when needed to simulate the vault. You should save the player’s designated position before the animation ends to keep their position, as when animations end the player will return to their original position.
Depending on how complex you want the system to be, you might want to create different animations depending on the context. For instance, the player might do a quick vault if the vault is done while sprinting, while a different animation could be used if the player is moving normally.
So basically, teleport the player to their designated position once the animation ends? How would I make the position accurate to where the animation landed? Animations don’t change the players position.
Is it possible for a more physics based method? I really dont want to rely on animations for positioning, if the animation and the position I teleport the player to are different, it will look like the player just teleported, which I dont want them to see.
Physics can certainly be used as well. I’m not very experienced with the physics side of Roblox, but I assume you could just apply a force to the character or mess around with the physics constraints to create a rough estimate of the vault path. ImpulseForce or an AlignPosition constraint could be good starting methods.
To me it seems to be a bit of trial and error. Experiment!
You could just make the vaulting part CanCollide false, but if you’re trying to find the position to teleport to you would need to use the LookVector of the character’s cframe.