Edit: Sorry guys! Im stupid… I use “SmoothShiftLock” Module which is a remake of the roblox shiftlock. I have found a solution but that stands in my way. Haha (Im so dumb)
Hello!
I made this land mechanic. Its supposed to detect when you fall from a certain threshold distance and trigger an animation, some effects and whatnot.
However, there is still one problem.
Video Examples:
You can turn your character while this mechanic plays out. Anyone know how to stop that?
I want it so even if you turn your camera. The characters keeps going in the direction they landed.
This is the code that I use.
local LandModule = {}
--//Services
local Players = game:GetService("Players")
local DebrisService = game:GetService("Debris")
local RunService = game:GetService("RunService")
local TweenService = game:GetService("TweenService")
local StarterPlayer = game:GetService("StarterPlayer")
local UserInputService = game:GetService("UserInputService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ServerScriptService = game:GetService("ServerScriptService")
--//Global Variables
local Player = Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")
local RootPart = Character:WaitForChild("HumanoidRootPart")
local Animator = Humanoid:WaitForChild("Animator")
local Camera = workspace.CurrentCamera
--//Resources
local ReplicatedAssets = ReplicatedStorage.Assets
local Animations = ReplicatedAssets.Animations
local SFX = ReplicatedAssets.SFX
local VFX = ReplicatedAssets.Effects
--//Modules
local Modules = ReplicatedStorage.Modules
local GlobalModule = require(Modules.Effects.Global)
local ContextUtility = require(script.Parent.Parent.Parent.Utility.Context)
local MaidModule = require(Modules.Utility.Cleaners.Maid)
local Maid = MaidModule.new()
--//Animations
local MovementAnimations = Animations.Movement
local MiscMovementAnimations = MovementAnimations.Misc
local LandAnimation = Animator:LoadAnimation(MiscMovementAnimations.SoftLand)
LandAnimation.Priority = Enum.AnimationPriority.Action4
--//Sounds
local MovementSfx = SFX.Movement
local LandSounds = MovementSfx.Lands
local LandSound = LandSounds.SoftLand
--//UtilityFunctions
local function GlobalModuleEffects(Magnitude,Roughness,DurationBetweenStun,Anchored,HighlightDelay,HightlightTime,BlurDelay,BlurTime)
Maid:GiveTask(task.spawn(function()
Maid:GiveTask(task.spawn(function()
GlobalModule.Highlight(HighlightDelay,HightlightTime,Character)
GlobalModule.Blur(BlurDelay,BlurTime,Character)
end))
end))
end
local function BodyVelocity(Power,Duration)
local RootVector = RootPart.CFrame.LookVector
local BodyVelocity = Instance.new("BodyVelocity", RootPart)
BodyVelocity.MaxForce = Vector3.new(0,0,math.huge)
BodyVelocity.P = 1000
BodyVelocity.Velocity = CFrame.new(RootPart.Position,RootPart.Position + Vector3.new(RootVector.X,0,RootVector.Z)).LookVector * Power
DebrisService:AddItem(BodyVelocity,Duration)
end
--//ModuleFunctions
function LandModule.Land()
GlobalModuleEffects(4,4,1,false,0,.5,0,.7)
LandAnimation:Play()
LandSound:Play()
BodyVelocity(25,.5)
ContextUtility.FreezeMovement(0.7)
Maid:GiveTask(task.spawn(function()
local SavedWalkSpeed = Humanoid.WalkSpeed
Humanoid.WalkSpeed = 0
Humanoid.AutoRotate = false
LandAnimation.Stopped:Connect(function()
Humanoid.WalkSpeed = SavedWalkSpeed
Humanoid.AutoRotate = true
end)
end))
end
return LandModule
Thank you!