How would I go about making this? I can do all the HUD etc, but how would I make the actual game above the chat and to the left of inventory / map. As it’s enclosed? Any idea how to do this even if it’s simple, then please help, I’m stuck at this. Thanks in advance!
EDIT: Haha, figured something out that’ll do. I put the scripts on a gameobject instead of the camera, thought they had to be on the camera to be shown. If there’s a better way for this let me know ;p
1 Answer
1
You can set variable “Viewport Rect” either from the inspector, or from code. This specify whit section of the screen the given camera will occupy. You can do this to limit the output of the camera as you describe, or even for split-screen multiplayer.
BTW: if you want clicks outside of the camera to be ignored by certain scripts, all you have to do is check the mouse position and whether it is within the viewport of the camera or not.
Rect camViewport = Camera.main.rect;
Vector3 mousePos = Input.mousePosition;
if (mousePos.x >= camViewport.xMin && mousePos.x <= camViewport.xMax && mousePos.y >= camViewport.yMin && mousePos.y <= camViewport.yMax) {
// do something only when mouse is within the main game window
}
I don't understand what you want. Are you looking to have the game's viewport moved into the upper left corner so that there is room for the inventory and chat at the bottom right? You could easily do that with the Camera's Inspector options.
– luckruns0utI made a gameobject and put the GUI scripts onto it, then scaled the camera to fit correctly. What my problem is right now, is that when you click out of the camera (chat for example), it still moves with my click to move script. / it still acts as if I'm clicking inside the camera
– MadswintAssuming your game window will be a fixed size, can't you just check the mouse coordinates before running the click-to-move code to make sure that they are within the viewport?
– luckruns0utI am new to javascript and so far I have only 'fully' got the hand of unity's GUI system, said in another way, I wouldn't be able to code that since I dont know how to, yet. If I knew how to, I am sure I could use that.
– Madswint