I am currently working on a grass system.
It works like this: Using DotProduct, we find the position of the player relative to the blade of grass.
Then, if the player is located to the right of the object, and the player touches the object, the function is triggered (the blade of grass bends to the right). Also works the other way
I make it work on a modular script. I need to make sure that there is a check inside RenderStepped, and if the condition is met, then the function created in the Modular script is executed
RenderStepped:
RunService.RenderStepped:Connect(function()
local grassToCharacter = (char.Head.Position - v.Position).Unit
local grassLook = v.CFrame.LookVector
local dotProduct = grassToCharacter:Dot(grassLook)
if dotProduct < 0 then
--Left
else
--Right
end
end)
The problem is that you can’t put the Touch function in RenderStepped. What is the best way to do this?