I write this topic to seek help from others, even though there are very few existing threads talking about it (in other ways).
I had been thinking of creating additional type for my kart racing’s boost pad, “Forward”. This idea was inspired by what exists in non-Roblox game “Kartrider”, and its function is when player’s kart steps on it, the kart will be forcefully pushed forward with direction based on booster’s normalized and facing vector (X, _, Z axes) for short duration. (note that boost velocity blends current velocity of the kart)
I attempted to get it working by instancing new “BodyVelocity” or “LinearVelocity” to the kart hitbox with this code:
local ForwardDebounce = false
local MiniDebounce = false
local JumpDebounce = false
local StunDebounce = false
local function ForwardBoost(direction, boostPower, boostDuration)
ForwardDebounce = true
Values.IsForwardBoosting.Value = true
local bodyVelocity = Instance.new("LinearVelocity")
bodyVelocity.Name = "ForwardBoost"
bodyVelocity.MaxForce = math.huge
direction = Vector3.new(direction.X, 0, direction.Z).Unit
local Velocity = (direction * boostPower)
bodyVelocity.VectorVelocity = Vector3.new(Velocity.X, bodyBelocity.VectorVelocity.Y, Velocity.Z)
bodyVelocity.Parent = Main.Hitbox
--Thread:Wait(boostDuration)
local StartTime = os.clock() repeat Thread:Wait() until (os.clock() - StartTime) >= boostDuration
Values.IsForwardBoosting.Value = false
bodyVelocity:Destroy()
ForwardDebounce = false
end
I expected to see it doing well, it was overridden by existing BodyMover (Velocity)
In alternate method, I used AssemblyLinearVelocity, which was working, but only lasted very short time and not helpful much.
So the topic title says it all. I repeatedly ask you guys if there is better way to help me dealing with this.
P/S: merging boost and engine velocities into one would not be helpful for me to solve this