Hi there, I am working on a platformer style game and need collision detection (for walls) during certain actions, in this case dive and long jump.
I have connected heartbeat functions to these actions, and in the heartbeat call for this module for checking wall collisions
local Workspace = game:GetService("Workspace")
local Constants = require(game:GetService("ReplicatedStorage").Platformer.Constants)
local function handleWallCollision(characterController, raycastParams: RaycastParams)
local rootCFrame = characterController.root.CFrame
local checkOrigin = rootCFrame:PointToWorldSpace(Vector3.new(0, 0, -Constants.WALL_CHECK_RADIUS))
local checkDirection = rootCFrame.LookVector * (Constants.WALL_CHECK_RADIUS * 2)
local result = Workspace:Spherecast(checkOrigin, Constants.WALL_CHECK_RADIUS, checkDirection, raycastParams)
return result
end
return handleWallCollision
but this does not work well at all, it doenst detect collision if i initiate a dive when already touching the wall, and long jump collision doesnt always work if only the top half of my humanoid hits the wall