Hello, i need that the bodygyro rotate the board relativ to the wedge like: in the picture.
my try:
local scanner=script.Parent --> skateboard
local gyro=script.Parent.BodyGyro --> bodygyro in skateboard
while wait() do
local ray = Ray.new(scanner.Position, (scanner.Position - scanner.Position+Vector3.new(0,-3,0)).unit * 300)
local _part, position = workspace:FindPartOnRay(ray, scanner, false, true)
if _part~=nil then
gyro.CFrame=script.Parent.CFrame*_part.CFrame.fromAxisAngle --> my failed try
--- here i need a better line
end
end
You will be required to get the surface normal of whichever surface your board is on top of. Once you have it you can either construct a CFrame using two arguments(pos, lookAt) or just do some trigonometry.
You could try using the surface normal, as @ScripterGo said.
local scanner=script.Parent --> skateboard
local gyro=script.Parent.BodyGyro --> bodygyro in skateboard
while wait() do
local ray = Ray.new(scanner.Position, (scanner.Position - scanner.Position+Vector3.new(0,-3,0)).unit * 300)
local _part, position, surfaceNormal = workspace:FindPartOnRay(ray, scanner, false, true)
if _part~=nil then
gyro.CFrame = CFrame.new(Vector3.new(), surfaceNormal)
end
end
What if you used a BodyVelocity, and made the velocity in the lookVector direction? If you do this, you wont need a bodyGyro to move along the wedges because the bodyVelocity will cause the object conform to shape of the ramp.