Questions about WorldtoViewportPoint

I have a few questions about the WorldtoViewportPoint function, that I don’t know how to fix.

  1. How do I detect if a part is off screen? [The part is behind me]

    .
  2. How do I detect if a part is partly behind a wall?

    .
  3. How do I detect if a part is fully behind a wall?
  1. How do I make the camera (in this case, it’s the Baseplate, because I’m making a top-down game) move with the player?

  2. I have a script that makes the Baseplate move towards the player, so that way the player is always in the center of the screen. Whenever I run the game, and the Baseplate moves, I get a ton of errors saying that I have to turn the Baseplate’s location into a Vector3. How can I do that?

  3. How would I be able to set the Baseplate’s CFrame?

Any answers and help would be appreciated.

(i know the Baseplate is not the camera, and that it’s just a part, but I’m making a top-down game, and it’s the baseplate that the player stands on.)

Here is the script that moves the Baseplate towards the player

local Player = game.Players.LocalPlayer local Mouse = Player:GetMouse() local Baseplate = workspace.Baseplate local BaseplatePosition = Baseplate.Position local BaseplateSize = Baseplate.Size local BaseplateWidth = BaseplateSize.X local BaseplateLength = BaseplateSize.Z local BaseplateCenter = BaseplatePosition + Vector3.new(BaseplateWidth/2, 0, BaseplateLength/2) while wait(1) do local MousePoint = Mouse.Hit.p local BaseplateCFrame = CFrame.fromMatrix(Vector3.new(MousePoint.x, 1, MousePoint.z), Vector3.new(0,0,0)) Baseplate.CFrame = BaseplateCFrame end

Anyone know what all the problems are?

Solutions/Answers:

Answer 1:

  1. How do I make the camera (in this case, it’s the Baseplate, because I’m making a top-down game) move with the player? local Player = game.Workspace.Player local Mouse = Player:GetMouse() local Baseplate = workspace.Baseplate local BaseplatePosition = Baseplate.Position local BaseplateSize = Baseplate.Size local BaseplateWidth = BaseplateSize.X local BaseplateLength = BaseplateSize.Z local BaseplateCenter = BaseplatePosition + Vector3.new(BaseplateWidth/2, 0, BaseplateLength/2) while wait(1) do local MousePoint = Mouse.Hit.p local BaseplateCFrame = CFrame.fromMatrix(Vector3.new(MousePoint.x, 1, MousePoint.z), Vector3.new(0,0,0)) Baseplate.CFrame = BaseplateCFrame end 2. I have a script that makes the Baseplate move towards the player, so that way the player is always in the center of the screen. Whenever I run the game, and the Baseplate moves, I get a ton of errors saying that I have to turn the Baseplate’s location into a Vector3. How can I do that? local Player = game.Workspace.Player local Mouse = Player:GetMouse() local Baseplate = workspace.Baseplate local BaseplatePosition = Baseplate.Position local BaseplateSize = Baseplate.Size local BaseplateWidth = BaseplateSize.X local BaseplateLength = BaseplateSize.Z local BaseplateCenter = BaseplatePosition + Vector3.new(BaseplateWidth/2, 0, BaseplateLength/2) while wait(1) do local MousePoint = Mouse.Hit.p local BaseplateCFrame = CFrame.fromMatrix(Vector3.new(MousePoint.x, 1, MousePoint.z), Vector3.new(0,0,0)) Baseplate.CFrame = BaseplateCFrame end 3. How would I be able to set the Baseplate’s CFrame? local Player = game.Workspace.Player local Mouse = Player:GetMouse() local Baseplate = workspace.Baseplate local BaseplatePosition = Baseplate.Position local BaseplateSize = Baseplate.Size local BaseplateWidth = BaseplateSize.X local BaseplateLength = BaseplateSize.Z local BaseplateCenter = BaseplatePosition + Vector3.new(BaseplateWidth/2, 0, BaseplateLength/2) while wait(1) do local MousePoint = Mouse.Hit.p local BaseplateCFrame = CFrame.fromMatrix(Vector3.new(MousePoint.x, 1, MousePoint.z), Vector3.new(0,0,0)) Baseplate.CFrame = BaseplateCFrame end

Answer 2:

Answer 3:

I see a few issues in your code, here’s the correction: local Player = game.Works

Onscreen:
local vector,onscreen = camera:WorldToViewportPoint

If you want to check if a part is behind a wall, you have to shoot raycasts since i believe roblox does not have a direct function for that.