Hello!
To get to the point basically…
I am making a stage in an obby where you navigate a raft using the A/D keys. The raft is supposed to move forward and turn left/right when a or d is pressed. The issue in hand im facing is that the raft model doesnt rotate along with the rafts root part orientation. The code takes the root parts Y orientation into account so im not exactly sure myself why its not rotating?
Just in case! the semi-transparent box on the raft is the root part.
Video of the issue:
Any help would be really appreciated since im on a somewhat tight deadline i need this stage to be done in 3 hrs.
Code:
local Model = self.Model
local Input = InptuClass.new()
local Char = self.Player.Character
local RaftRoot = Model.PrimaryPart
local Direction = CFrame.new(0,0,Settings.Speed)
self.Paddle:Play()
Input.Triggered = function(InputDir: string)
if InputDir == "left" then
Direction = CFrame.new(Settings.Speed,0,Settings.Speed)
game.TweenService:Create(RaftRoot,TweenInfo.new(.5,Enum.EasingStyle.Linear,Enum.EasingDirection.Out), {
Orientation = Vector3.new(0,-50,0)
}):Play()
elseif InputDir == "right" then
Direction = CFrame.new(-Settings.Speed,0,Settings.Speed)
game.TweenService:Create(RaftRoot,TweenInfo.new(.5,Enum.EasingStyle.Linear,Enum.EasingDirection.Out), {
Orientation = Vector3.new(0,50,0)
}):Play()
elseif InputDir == "forward" then
Direction = CFrame.new(0,0,Settings.Speed)
game.TweenService:Create(RaftRoot,TweenInfo.new(.5,Enum.EasingStyle.Linear,Enum.EasingDirection.Out), {
Orientation = Vector3.new(0,-90,0)
}):Play()
end
end
Mover.Move(function() -- Move binds a callback to renderstepped and unbinds it if the callback returns true.
local Pivot = Model:GetPivot()
local Hit = Raycast(RaftRoot.Position,RaftRoot.CFrame.LookVector*7,{Model,Char},Enum.RaycastFilterType.Exclude)
local IsStone = Hit and Hit.Instance:IsA("Terrain") and Hit.Material == Enum.Material.Basalt
if IsStone then
self:Destroy()
return true
end
Model:PivotTo(CFrame.new(Pivot.X,RaftRoot.Position.Y,Pivot.Z)*CFrame.Angles(0,math.rad(RaftRoot.Orientation.Y),0)*Direction)
--Model:PivotTo(Model:GetPivot()*CFrame.Angles(0,math.rad(RaftRoot.Orientation.Y),0))
return false
end)