I’m making a Donkey Kong game and in the first level you have these rolling barrels, now I want to detect when a player jumps over a barrel so that they get to score points like in the original arcade.
I have no idea how I would do this …
Any ideas?
In the video you get to see the barrels:
Would be inefficient but you canput an object above the player and when the player touches it you give em score
Perhaps add score every time 10 seconds passed instead?
I want that points can only be earned by jumping over a barrel, but thanks for the idea
Maybe you could try raycasting
Maybe you can weld a part to the barrels that gives the player a point when they touch it?
Wouldn’t the barrels rolling cause a problem, how does that work?
Turn CanCollide off, turn CanTouch on, should work perfectly.
Using Raycast can help detect players jumping over barrels. I’m not sure if the code below will work but you can try it. Correct me if I’m wrong. Then you can use RunService to repeat the process of raycasting then maybe once it detect you can disconnect the RunService
local function detect_on_top(barrel, how_much_studs_upwards)
local raycast_params = RaycastParams.new()
-- put whatever parameters you want to blacklist the barrel from being raycasted or something
local rayresult = workspace:Raycast(barrel.Position, Vector3.yAxis * how_much_studs_upwards, raycast_params)
if rayresult then
local char = rayresult.Instance:FindFirstAncestorOfClass("Model")
if char then
if game.Players:GetPlayerFromCharacter(char) then
return true
end
end
end
return false
end
Why use run service ?? Why not just use humanoid. Jumping??
Because then it will only trigger at player jump state and when player jump they could be in front of the barrel instead of on top of the barrel
I see… Thx for the info
charssssssss