So i made a bounce move for my character. He’s supposed to fly towards the floor and bounce upwards as soon as he hits it. The “flying towards the floor” part works, but the bounce rarely does. When the bounce doesn’t work, the player just lands normally instead of being sent upwards a little. I would show a video showing the issue but the Devforum keeps on saying there’s an issue when i try to upload one. I’m pretty sure this issue is something physics related.
function Moveset:Tramp(TrampAnim: Animation, TrampReleaseAnim: Animation)
if self._Humanoid:GetState() == Enum.HumanoidStateType.Freefall and HasDJ and not IsTramping and not IsHovering and not IsDashing then
IsTramping = true
self._Root:ApplyImpulse(-self._Root.CFrame.UpVector * (120 * self._Root.AssemblyMass))
repeat
task.wait()
until self._Humanoid:GetState() ~= Enum.HumanoidStateType.Freefall
self._Root:ApplyImpulse(self._Root.CFrame.UpVector * (100 * self._Root.AssemblyMass))
IsTramping = false
end
end
You’re probably conflicting with a humanoid state. Humanoids have very weird physics kinks.
Try switching the humanoid to Physics state, then firing the impulse.
function Moveset:Tramp(TrampAnim: Animation, TrampReleaseAnim: Animation)
if self._Humanoid:GetState() == Enum.HumanoidStateType.Freefall and HasDJ and not IsTramping and not IsHovering and not IsDashing then
IsTramping = true
self._Root:ApplyImpulse(-self._Root.CFrame.UpVector * (120 * self._Root.AssemblyMass))
repeat
task.wait()
until self._Humanoid:GetState() ~= Enum.HumanoidStateType.Freefall
self._Humanoid:ChangeState(Enum.HumanoidStateType.Physics)
self._Root:ApplyImpulse(self._Root.CFrame.UpVector * (100 * self._Root.AssemblyMass))
--might need to run RunService:Heartbeat():Wait() so the impulsed force can be fully applied
self._Humanoid:ChangeState(Enum.HumanoidStateType.Landed)
IsTramping = false
end
end
It still does the same thing sadly…
Bump, still really need help with this.
This might be due to how you wait for the character to hit the ground. Instead of doing
repeat
task.wait()
until self._Humanoid:GetState() ~= Enum.HumanoidStateType.Freefall
use .StateChanged
instead. like so:
humanoid.StateChanged:Connect(function(oldState, newState)
if newState ~= Enum.HumanoidStateType.Freefall then
--whatever
end
end)
Source: https://create.roblox.com/docs/reference/engine/classes/Humanoid#GetState
(First time messing with humanoid states so forgive if I completely got this wrong lol)
It still won’t work, unfortunately.
Bump again, still need help with this issue.