You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? Keep it simple and clear!
I want to achieve a part that follows the player so my isometric game can work -
What is the issue? Include screenshots / videos if possible!
The ray that i have sent is hitting a set part, namedBaseplate
, and the higher you go, the worse it is to control the character -
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I tried to manually code it in, but it didn’t work.
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
Script that will be amended to fit this functionality
--//Variables//--
local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
local Character = Player.Character or Player.CharacterAdded:Wait()
local Camera = game.Workspace.CurrentCamera
local abs = math.abs
local Controller = require(game.Players.LocalPlayer.PlayerScripts:WaitForChild("PlayerModule")):GetControls()
local RunService = game:GetService("RunService")
function getInputDirection()
local direction = Controller:GetMoveVector()
return if abs(direction.X) > 0.001 or abs(direction.Z) > 0.001 then Vector3.new(direction.X, 0, direction.Z).Unit else Vector3.zero
end
Camera.CameraType = Enum.CameraType.Custom
--//Main Script//--
RunService:BindToRenderStep("MoveOverride", Enum.RenderPriority.Character.Value + 1, function()
if Player.Character then
Camera.FieldOfView = FieldOfView
local humanoid = Player.Character:FindFirstChild("Humanoid")
local hrp = Player.Character:FindFirstChild("HumanoidRootPart")
if humanoid and hrp then
--//Humanoid Movement.//--
local characterCFrame = hrp.CFrame
local fixedDirection = Vector3.zero
local inputDirection = getInputDirection()
if inputDirection ~= Vector3.zero then
fixedDirection = characterCFrame:VectorToWorldSpace(inputDirection)
end
humanoid:Move(fixedDirection, false)
--//Isometric Camera//--
game:GetService("SoundService"):SetListener(Enum.ListenerType.ObjectCFrame, Character.HumanoidRootPart)
Camera.CFrame = CFrame.new(Vector3.new(Character.HumanoidRootPart.Position.X + zoom, Character.HumanoidRootPart.Position.Y + zoom, Character.HumanoidRootPart.Position.Z + zoom), Character.HumanoidRootPart.Position)
--//Player Look//--
local mouseray = Mouse.UnitRay
local raycastparams = RaycastParams.new()
raycastparams.FilterDescendantsInstances = {workspace.Baseplate}
raycastparams.FilterType = Enum.RaycastFilterType.Include
local ray = workspace:Raycast(mouseray.Origin,mouseray.Direction.Unit * 1000, raycastparams)
if ray then
local raypos = ray.Position
local hrpypos = hrp.Position.Y
hrp.CFrame = CFrame.lookAt(hrp.Position,Vector3.new(raypos.X,hrpypos,raypos.Z))
end
end
end
end)