So I use Gravity Controller which controls the player’s Gravity using a Vector3 to set the correct force.
I already have a latch function which allows to player to change their gravity in order to latch to a wall under certain parameters. This is it:
Summary
function latch()
local origin = HRP.Position
local direction = HRP.CFrame.LookVector * REACH
local result = Workspace:Raycast(origin, direction, rayParams)
if not result then return end
latchingToWall = result.Normal
wait(0.5)
latchingToWall = nil
end
It uses Raycasting and if there are results then the players gravity is changed to those results.
What I basically am looking for is a way to do this same thing with .Touched.
I know that in raycasting result.normal returns a Vector3, so that is basically what I need to do within a Touched function that I am using, but I am not sure how. This is that function:
Summary
for i, v in pairs(character:GetChildren()) do
if v:IsA("BasePart") then
local touchcon
touchcon = v.Touched:Connect(function(touch)
if not character:FindFirstChild(touch.Name) then
Flying = false
print("flying false do to touch")
touchcon:Disconnect()
end
end)
end
end
I need a Vector3 from the point of contact that Touched runs on.