@@verpix4956 Pretty sure he modified it using a similar strategy to the ones found on the asset store. It just polishes it up and adds a few extra features such as max and min zoom, but yes its very similar to this as far as I know.
Thanks very much! I've had a great idea for a sim like management game for some time but never did stop to figure out how to make this type of camera setup. Your method is much smoother than my attempts! :) Appreciate the video very much. Looking forward to the next one!
For everyone who runs into problems with stuttering or jittering cameras here's a little advice that I wish was part of this video: Put ALL code that manipulates a cameras position or rotation in the LateUpdate() method not the Update()! This way you will ensure that nothing will move around after your cameras transform has already been updated during the frame.
Actually useful tutorial. After hundreds of others, that handle perspective camera zoom as FOV change - this is truly a breath of fresh air. Top tier, sir, top tier. Love it.
@@TheAwesomeAlan Clamp means clamping in Mathf.Clamp(), Clamp means that u "animate" a Cube from minZoom to maxZoom. I hope u understand Clamping now : )
I just did: // Clamp newPosition to the bounds of the map (hardcoded -- not great, but can be extracted to variables at any point) newPosition = new Vector3(Mathf.Clamp(newPosition.x, -7f, 7f), 0.1f, Mathf.Clamp(newPosition.z, -7f, 7f)); and in the zoom: // Clamp zoom to prevent clipping into mesh or zooming too far out newZoom = new Vector3(0, Mathf.Clamp(newZoom.y, 2, 12), Mathf.Clamp(newZoom.z, -12, -2));
Such an amazing help! I didn’t understand at first and I also didn’t make my camera the same way, but that is just more proof the concepts in the video are covered thoroughly! Thank you!
Sheesh, I can't believe this one is free and easy to avail. This cam controller is so much better than I what I had in mind. Thanks for this one, got me out of a headache. Still works Oct.2024 Unity 2022.3.34f1
The comments section is full of helpful tricks to make this better. Here is mine. If you use a logarithm on your zoom speed it will zoom farther the further away you get. Meaning the zoom will feel much more natural. It will also be a good idea to link your zoom into you panning speed. That way you can pan at quicker rate the further you get away negating the need for a faster pan speed. These are pretty complex functions that I'm still working on.
@@jern2216 use an exponential function ie y=x^2 where y = pan speed and x = your caneras offset from focus. Depending on your scale you'll need to play around with the equation to get desired results.
EXCELLENT! EXCELLENT! EXCELLENT! Thank you so much! This is far and away the best and most versatile cam controller I’ve found for top down! Thank you very much!
This... was a legit tutorial, thank you - I didn't attempt this yet but I am watching it again to practice. I had a plan today and watched a Unity camera tutorial which was done half assedly making assumptions about the viewers knowledge without providing references and spent nearly 6 hours researching to no avail. By comparison this was a breath of fresh air.
Thank you. Thank you so much. I am a long time gamer, script kitty programmer that finally has decided to give making content a shot. And in true self destructive fashion I have volunteered to make an RTS my first project. I am a glutton for punishment. Your camera set up is by for the most straight forward and descriptive means I have ever come across. This was an excellent video.
I am an absolute noob at game dev, but I've made such a camera controller in my "game" with a plane, a sphere and four cubes, and it feels sooo satysfying :D THANKS!
Nice. I spent 7 hours doing this on my own. I just couldn't be satisfied with what is default camera behaviour, so I revisited trigonometry and got going. I probably watched 2h of tutorials and read 50 posts. Noone did what I wanted. Now I lay in bed at 1am and then stumble upon this...
You could make the camera zoom and rotation a bit more intuitive (When looking at the gameobjects and values) by having another layer in between the camera and the rig called "Pivot", aligned with the camera. The camera would now only need to move on one axis to zoom, the "pivot" would handle rotation, and the "rig" would move across the landscape.
Wow... Being born and raised with FPSes, the 'issue' during the first 2 minutes of the video would've never occurred to me lol... I legitimately saw nothing wrong for the longest time... But thinking about how I would walk-around and view a table-top game... it all clicks! Bottom-line, excellent designing and scripting!
Love the quality of this tutorial. Simple and straight forward but dives deep with all the features you would want in a Strategy Game camera. Cant wait to see more tutorials from you!
Your tutorials are absolutely amazing 😍 I am starting to prototype a new tower defense game and this will be a great rig for my camera. Thank you very much for this.
Nice tutorial, I found your video on a reddit post on unity 3d. I really liked the way you teach and your patience to explain everything. Also, the quality production is amazing. Keep going
Thank you. This is exactly the information that I was looking for starting my new project. Will definitely look around your channel more for even more helpful guides
Regarding "fast mode" : Draw inspiration from Supreme Commander and other strategy games that modify your speed by your zoom ( in a very organic way ). AKA, further out = faster, closer in = slower. This also helps to establish feelings of scale and give a very pleasing way of controlling your camera speed.
Interesting fact: the thing with the „fake orthographic view“ works in real life. If you use a tele photo lens (200mm+) you will loose nearly all perspective in the picture. In a 3D Mockup Tool, i missed an orthographic view. So i just used a 5000mm camera lens and put it far, far away and here you go. It just explained to me why this works and i found it really interesting. So i just randomly share these thoughts, maybe someone ist interested✌🏼
Thank you so much. I am new to Unity and am trying to create a game I have in my head. I’ve been having to figure out Isometric game design with its lack of tutorial and resources has been frustrating. This camera setup will let me make the game in 3D where there is just much much more tutorials and resources for.
If you have problems with ROTATION not working (saw some in the comments): - set the rigs position to null - add 3D-Object > Cube to the rig to make its position visible - then take the map / terrain / level and made its ground touch the cube - now try to rotate again, it should work now Explanation: many (including me at first) think the rig has to be above the terrain, somewhere in the air. But it should be level with the ground. You will understand the issue better once the rig is visible to you. Hope this helps, cheers.
I had this problem and your solution helped me fix it, thanks! The problem was it was rotating around the rig's position (what it's meant to do) but my rig was somewhere absolutely useless.
Great video mate. I learned a lot and was able to take this as a base template to modify further for my own work. As a professional software engineer in a space close to games, I wanted to give you a tip I think would be helpful for your viewers. There were a few times where you used mathematical, or more specifically computer graphic related concepts empowered by linear algebra, that you would only speak of what to write and not a lot of explanation behind the specific mathematical operation applied and its significance in bringing to life what you were achieving. I fear that this can lead to your viewers simply point blank taking the code without truly understanding the math behind it and it can lead to them not really learning a bunch but having snippets of code copy pasted from various sources to implement their game. While this is definitely totally cool, I think people would benefit from the extra details by a lot and it would spark more curiosity in them to learn further about the topic and develop their own creativeness with it, like you have. I also totally understand that for UA-cam purposes a lot of things have to be done quickly to avoid prolonged videos that people don't completely watch, so maybe even some links that explain the concepts used would be really helpful too! Overall, great work, your channel is amazing, and keep it up!
Great turorial! For anyone trying to clamp the zoom and finding the other examples below don't work, try this really simple one it works perfectly for me public float maxZoom, minZoom; // I set these to -100 and -700 in inspector (then in HandleMouseInput replace the scroll bit with below) if(Input.mouseScrollDelta.y!=0) { if(Input.mouseScrollDelta.y>0 && newZoom.z < maxZoom) { newZoom += Input.mouseScrollDelta.y * zoomAmount; } if (Input.mouseScrollDelta.y < 0 && newZoom.z > minZoom) { newZoom += Input.mouseScrollDelta.y * zoomAmount; } }
@@thomascrozelon1648 I'm sure you figured this out by now, but all you have to do is add that extra && segment to the if statement (I used different variable names): if(Input.GetKey(KeyCode.R) && newZoom.z < zoomInConstraint) { newZoom += zoomAmount; } if(Input.GetKey(KeyCode.F) && newZoom.z > zoomOutConstraint) { newZoom -= zoomAmount; }
Okay I still use this camera controller all the time. Its simple and I really like it but I did resolve the zoom lock and a new way of calculating zoomAmount so that its a little bit friendlier (imo). There's a number of comments talking about a clamp on the zoom which kinda worked for me but its not quite on the money. To handle the zoom lock I did the below. Worked like a charm and keeps things simple since its along one axis in the variables. This allows you to set a min and max along the y axis without creating the "square" motion behavior in the dual clamps on y and z. I put the below directly in front of the bottom section of code where the final values are passed back to the camera. if (newZoom.y = maxZoom) { newZoom = camTransform.localPosition; } The other change that I made was to actually calculate the zoomAmount based on the assigned angle on the X camera rotation. The video tutorial works well for a 45 deg angle but breaks down if you aren't doing the math for a different angle. So add the below in the start to calculate the zoomAmount based on the angle you chose when you lined things up in the editor. var deltaZ = zoomAmount.y / Mathf.Tan(camTransform.eulerAngles.x * Mathf.Deg2Rad); zoomAmount = new Vector3(0, zoomAmount.y, -deltaZ); This let me play with a pseudo isometric feel for a cozy game. Super handy.
This was an interesting tutorial and I like the concepts. Since I had issues with the camera transform for my particular type of game, I ended up with a solution of zooming by changing the camera's FOV, as tweaking the FOV was something we already did in the video. The function to handle zooming works like this, and requires a public/serialized reference to the camera. I also made it so that holding the Shift key makes this zoom faster. void HandleZoomInput() { string axis = "Mouse ScrollWheel"; float zoomAmount = Input.GetKey(KeyCode.LeftShift) ? fastZoomAmount : defaultZoomAmount; if (Input.GetAxis(axis) != 0) { float val = Input.GetAxis(axis) * zoomAmount * Time.deltaTime; camera.fieldOfView -= val; } //Check if within bounds if (camera.fieldOfView > minZoomAmount) { camera.fieldOfView = minZoomAmount; } else if (camera.fieldOfView < maxZoomAmount) { camera.fieldOfView = maxZoomAmount; } } There are probably better solutions to ensuring that the zoom stays within the bounds but this was one option for me.
btw, to anyone wanting a zoom with the scroll wheel, literaly just do this. if (Input.GetAxis("Mouse ScrollWheel") > 0f) { newZoom += zoomAmount; } if (Input.GetAxis("Mouse ScrollWheel") < 0f) { newZoom -= zoomAmount; }
This was very helpful. One thing I did find is that I had to multiply my "movementSpeed" by Time.deltaTime when it got changed by the keyboard. If I didn't then it would have difference speeds at different framerates. I tested it at 10, 30, 60, and 300 FPS using Application.targetFramerate
Absolutely amazing video, exactly the type of camera i was looking for. You should make a tycoon/simulation game asset for the store, I would buy it instantly :)
Very cool video mate, honestly you make some really informative stuff! Just wondering, do you think you could do a video on creating a Camera Controller but for a 3rd Person 3D-Platformer? Would love to see one of those!
Nice video! Loved it! But I have one question. How do I make a boundary around the scene, that the camera will stay inside? - Mostly just so the player doesn't move way out of the game.
Love love love your videos! Can't wait to see your rpg series! (If that's in the works) I really want to do turn based combat properly with items, camera events, etc.
Brilliant video! One think that I wanted in my game is to have a smooth transition when you start following/focusing an game object. Hint for anyone needing the same: You can easily do that by setting the newPosition variable in HandleMovementInput() method to be equal to followTransform.position, like that: if (Input.GetKey(KeyCode.F)) // I removed the F binding from zoom because I allow zoom only via mouse. { newPosition = followTransform.position; }
hello, i tried doing what you said as it is a cool feature but it doesn't seem to work for me (maybe i'm too much of a beginner...), so could you explain a bit more please ? :D
I'm having a problem with the mouse camera movement for panning and rotation. The panning shoots the camera off into oblivion and it doesn't necessarily go in the correct direction and the rotation is very jittery when holding it and when dragging it the screen freaks out until its let go and then it moves. This is a really good tutorial and I can't figure out what the problem is, maybe its framerates or something but I really need help with this. Keyboard controls work perfectly though.
Oh sweet. Really high quality tutorial. Very recommendable.
Wait did you use this for Islanders!?!
Hi jonas
@@verpix4956 Pretty sure he modified it using a similar strategy to the ones found on the asset store. It just polishes it up and adds a few extra features such as max and min zoom, but yes its very similar to this as far as I know.
If Jonas is here then I guess im set
Come on Jonas answear him..how did you make it in your game
Excellent video! The comparison between the old ortho vs perspective but low FOV was eye opening for me.
Right? I imagine it was just as eye opening as when I figured that out myself! 😂
This is honestly one of the best unity tutorials I have ever seen!
Thanks very much! I've had a great idea for a sim like management game for some time but never did stop to figure out how to make this type of camera setup. Your method is much smoother than my attempts! :) Appreciate the video very much. Looking forward to the next one!
For everyone who runs into problems with stuttering or jittering cameras here's a little advice that I wish was part of this video: Put ALL code that manipulates a cameras position or rotation in the LateUpdate() method not the Update()! This way you will ensure that nothing will move around after your cameras transform has already been updated during the frame.
Wow! Thank you! I thought all time that the problems is in the postprocessing. Great my problem is solved! ;)
it doesnt work
Also, if your using rigidbodies with Physics that the camera follows, put them in FixedUpdate so the Camera moves with the physics updates
thanks
This didn't help mine unfortunately
谢谢!
Actually useful tutorial. After hundreds of others, that handle perspective camera zoom as FOV change - this is truly a breath of fresh air. Top tier, sir, top tier. Love it.
One thing we didn't cover here is how to limit the zoom and the pan of the camera so it won't go off world. Excellent stuff as always though.
Maybe it's not ideal but I ended up doing:
private void HandleZoom()
{
if (Input.mouseScrollDelta.y != 0)
{
newZoom += Input.mouseScrollDelta.y * zoomSpeed;
newZoom.y = Mathf.Clamp(newZoom.y, minZoom, maxZoom);
newZoom.z = Mathf.Clamp(newZoom.z, minZoom, maxZoom);
cameraTransform.localPosition = Vector3.Lerp(cameraTransform.localPosition, newZoom, Time.deltaTime * movementTime);
}
}
@@betomaluje Clamping the positions is the ideal way :D
@@cankarkadev9281 Could you elaborate on maybe what that'd look like? Or is what Alberto did what you're referring to?
@@TheAwesomeAlan Clamp means clamping in Mathf.Clamp(), Clamp means that u "animate" a Cube from minZoom to maxZoom. I hope u understand Clamping now : )
I just did:
// Clamp newPosition to the bounds of the map (hardcoded -- not great, but can be extracted to variables at any point)
newPosition = new Vector3(Mathf.Clamp(newPosition.x, -7f, 7f), 0.1f, Mathf.Clamp(newPosition.z, -7f, 7f));
and in the zoom:
// Clamp zoom to prevent clipping into mesh or zooming too far out
newZoom = new Vector3(0, Mathf.Clamp(newZoom.y, 2, 12), Mathf.Clamp(newZoom.z, -12, -2));
The BEST tutorial you can found for RTS camera
Such an amazing help! I didn’t understand at first and I also didn’t make my camera the same way, but that is just more proof the concepts in the video are covered thoroughly! Thank you!
11:45 - Impressed by your commitments 🙏🏼
Was wanting to see mouse interactions.
If you ever even think of making a Strategy game, You must watch this!
Amazing tutorial!
Thank you!
Sheesh, I can't believe this one is free and easy to avail. This cam controller is so much better than I what I had in mind. Thanks for this one, got me out of a headache. Still works Oct.2024 Unity 2022.3.34f1
The comments section is full of helpful tricks to make this better. Here is mine. If you use a logarithm on your zoom speed it will zoom farther the further away you get. Meaning the zoom will feel much more natural. It will also be a good idea to link your zoom into you panning speed. That way you can pan at quicker rate the further you get away negating the need for a faster pan speed. These are pretty complex functions that I'm still working on.
Very helpful tip!!
I will try this
Sorry, but how do I implement this?
@@jern2216 use an exponential function ie y=x^2 where y = pan speed and x = your caneras offset from focus. Depending on your scale you'll need to play around with the equation to get desired results.
EXCELLENT! EXCELLENT! EXCELLENT! Thank you so much! This is far and away the best and most versatile cam controller I’ve found for top down! Thank you very much!
This... was a legit tutorial, thank you - I didn't attempt this yet but I am watching it again to practice. I had a plan today and watched a Unity camera tutorial which was done half assedly making assumptions about the viewers knowledge without providing references and spent nearly 6 hours researching to no avail. By comparison this was a breath of fresh air.
Thank you. Thank you so much. I am a long time gamer, script kitty programmer that finally has decided to give making content a shot. And in true self destructive fashion I have volunteered to make an RTS my first project. I am a glutton for punishment. Your camera set up is by for the most straight forward and descriptive means I have ever come across. This was an excellent video.
I am an absolute noob at game dev, but I've made such a camera controller in my "game" with a plane, a sphere and four cubes, and it feels sooo satysfying :D THANKS!
Nice. I spent 7 hours doing this on my own. I just couldn't be satisfied with what is default camera behaviour, so I revisited trigonometry and got going. I probably watched 2h of tutorials and read 50 posts. Noone did what I wanted.
Now I lay in bed at 1am and then stumble upon this...
Quite literary all you need to hear about camera movement in 1 simple to follow tutorial. Thanks for this! Like.... a lot!
You could make the camera zoom and rotation a bit more intuitive (When looking at the gameobjects and values) by having another layer in between the camera and the rig called "Pivot", aligned with the camera. The camera would now only need to move on one axis to zoom, the "pivot" would handle rotation, and the "rig" would move across the landscape.
Dude what a high quality of a tutorial. Im so amazed. Huge respect u have a new fan and subscriber 😊
Wow...
Being born and raised with FPSes, the 'issue' during the first 2 minutes of the video would've never occurred to me lol...
I legitimately saw nothing wrong for the longest time...
But thinking about how I would walk-around and view a table-top game... it all clicks!
Bottom-line, excellent designing and scripting!
absolutely fantastic tutorial. gold!
Love the quality of this tutorial. Simple and straight forward but dives deep with all the features you would want in a Strategy Game camera. Cant wait to see more tutorials from you!
Your tutorials are absolutely amazing 😍 I am starting to prototype a new tower defense game and this will be a great rig for my camera. Thank you very much for this.
Thank you for your excellent video. Now I can make a camera controller for my strategy game.
Excellency! Can't describe how clear and well-rounded your tutorial is.
Thank you so much! I used this code in my Master Thesis and just now I implemented it in a project for my job. Much appreciated!!
well i've done it years ago..i was surprise many people don't use this trick..but this is nice tutorial delivery...i am subbing..
i know this video is very old.. but this was a beautiful tutorial.. well spoken, easy to follow and fantastic results A+
Nice tutorial, I found your video on a reddit post on unity 3d. I really liked the way you teach and your patience to explain everything. Also, the quality production is amazing. Keep going
Thanks for the wonderful lesson. UA-cam needs more Unity's awesome tutorial like this. I liked and subscribed.
Thank you. This is exactly the information that I was looking for starting my new project. Will definitely look around your channel more for even more helpful guides
Regarding "fast mode" : Draw inspiration from Supreme Commander and other strategy games that modify your speed by your zoom ( in a very organic way ). AKA, further out = faster, closer in = slower. This also helps to establish feelings of scale and give a very pleasing way of controlling your camera speed.
How do I do that?
Big thanks for this video! I've managed to create a solar system tactical overview using your video and applying it to the new Unity input system!
this is a BEAUTIFUL piece of work.
Thank you, I really like the way you lectured this. It has helped me immensely.
Interesting fact: the thing with the „fake orthographic view“ works in real life. If you use a tele photo lens (200mm+) you will loose nearly all perspective in the picture.
In a 3D Mockup Tool, i missed an orthographic view. So i just used a 5000mm camera lens and put it far, far away and here you go.
It just explained to me why this works and i found it really interesting. So i just randomly share these thoughts, maybe someone ist interested✌🏼
Great work dude, exactly what i was looking for. Im currently moving from c++ to unity and it helps to have some nice tutorials to get my head round.
Very easy to understand .great tutorial and great tutor.
This was fantastic! I really found this to be incredibly helpful. You do a great job in teaching and explaining all these details. Keep it up!
Thank you so much. I am new to Unity and am trying to create a game I have in my head. I’ve been having to figure out Isometric game design with its lack of tutorial and resources has been frustrating.
This camera setup will let me make the game in 3D where there is just much much more tutorials and resources for.
Wow thanks so much I learnt so many things from this short video very amazing and to tjw point with great explaining 💫
Great video as always. Best Unity videos on youtube by far !
Thanks so much!
Thank you very Much, now I can start developing basic Mechanics based on this!
If you have problems with ROTATION not working (saw some in the comments):
- set the rigs position to null
- add 3D-Object > Cube to the rig to make its position visible
- then take the map / terrain / level and made its ground touch the cube
- now try to rotate again, it should work now
Explanation: many (including me at first) think the rig has to be above the terrain,
somewhere in the air. But it should be level with the ground. You will understand
the issue better once the rig is visible to you. Hope this helps, cheers.
I had this problem and your solution helped me fix it, thanks! The problem was it was rotating around the rig's position (what it's meant to do) but my rig was somewhere absolutely useless.
You can alternatively add a widget to the rig with the button beside where you name it in the inspector.
Thank you !
newRotation *= Quaternion.AngleAxis(rotationAmount, transform.up);
Great video mate. I learned a lot and was able to take this as a base template to modify further for my own work. As a professional software engineer in a space close to games, I wanted to give you a tip I think would be helpful for your viewers. There were a few times where you used mathematical, or more specifically computer graphic related concepts empowered by linear algebra, that you would only speak of what to write and not a lot of explanation behind the specific mathematical operation applied and its significance in bringing to life what you were achieving.
I fear that this can lead to your viewers simply point blank taking the code without truly understanding the math behind it and it can lead to them not really learning a bunch but having snippets of code copy pasted from various sources to implement their game. While this is definitely totally cool, I think people would benefit from the extra details by a lot and it would spark more curiosity in them to learn further about the topic and develop their own creativeness with it, like you have.
I also totally understand that for UA-cam purposes a lot of things have to be done quickly to avoid prolonged videos that people don't completely watch, so maybe even some links that explain the concepts used would be really helpful too!
Overall, great work, your channel is amazing, and keep it up!
Very clear and well-produced tutorial! impressive.
Incredible that this tutorial is free. Well done, super useful!
Great video! Easy to implement and yet fully functional!!
Thanks for this, it's exactly what I wanted for my game.
Love the isometric with depth trick! Thanks and great tutorial!
Great turorial! For anyone trying to clamp the zoom and finding the other examples below don't work, try this really simple one it works perfectly for me
public float maxZoom, minZoom; // I set these to -100 and -700 in inspector
(then in HandleMouseInput replace the scroll bit with below)
if(Input.mouseScrollDelta.y!=0)
{
if(Input.mouseScrollDelta.y>0 && newZoom.z < maxZoom)
{
newZoom += Input.mouseScrollDelta.y * zoomAmount;
}
if (Input.mouseScrollDelta.y < 0 && newZoom.z > minZoom)
{
newZoom += Input.mouseScrollDelta.y * zoomAmount;
}
}
It workied perfectly with the mouse indeed, but do you have any idea how to do it for keyboard?
@@thomascrozelon1648 I'm sure you figured this out by now, but all you have to do is add that extra && segment to the if statement (I used different variable names):
if(Input.GetKey(KeyCode.R) && newZoom.z < zoomInConstraint)
{
newZoom += zoomAmount;
}
if(Input.GetKey(KeyCode.F) && newZoom.z > zoomOutConstraint)
{
newZoom -= zoomAmount;
}
Idk why but it doesn't work for me
@@aurl3119 just use clamp
@@SaiponathGames How do you use clamp?
Okay I still use this camera controller all the time. Its simple and I really like it but I did resolve the zoom lock and a new way of calculating zoomAmount so that its a little bit friendlier (imo). There's a number of comments talking about a clamp on the zoom which kinda worked for me but its not quite on the money.
To handle the zoom lock I did the below. Worked like a charm and keeps things simple since its along one axis in the variables. This allows you to set a min and max along the y axis without creating the "square" motion behavior in the dual clamps on y and z.
I put the below directly in front of the bottom section of code where the final values are passed back to the camera.
if (newZoom.y = maxZoom)
{
newZoom = camTransform.localPosition;
}
The other change that I made was to actually calculate the zoomAmount based on the assigned angle on the X camera rotation. The video tutorial works well for a 45 deg angle but breaks down if you aren't doing the math for a different angle. So add the below in the start to calculate the zoomAmount based on the angle you chose when you lined things up in the editor.
var deltaZ = zoomAmount.y / Mathf.Tan(camTransform.eulerAngles.x * Mathf.Deg2Rad);
zoomAmount = new Vector3(0, zoomAmount.y, -deltaZ);
This let me play with a pseudo isometric feel for a cozy game. Super handy.
The intro is EPIC
This was an interesting tutorial and I like the concepts.
Since I had issues with the camera transform for my particular type of game, I ended up with a solution of zooming by changing the camera's FOV, as tweaking the FOV was something we already did in the video.
The function to handle zooming works like this, and requires a public/serialized reference to the camera.
I also made it so that holding the Shift key makes this zoom faster.
void HandleZoomInput() {
string axis = "Mouse ScrollWheel";
float zoomAmount = Input.GetKey(KeyCode.LeftShift)
? fastZoomAmount : defaultZoomAmount;
if (Input.GetAxis(axis) != 0) {
float val = Input.GetAxis(axis) * zoomAmount
* Time.deltaTime;
camera.fieldOfView -= val;
}
//Check if within bounds
if (camera.fieldOfView > minZoomAmount) {
camera.fieldOfView = minZoomAmount;
} else if (camera.fieldOfView < maxZoomAmount) {
camera.fieldOfView = maxZoomAmount;
}
}
There are probably better solutions to ensuring that the zoom stays within the bounds but this was one option for me.
I love your sense of humor! :D Also great content as always on this channel.
Thank you. This is what I was looking for
Brilliant video mate! Thank you for putting it together. Also, I enjoyed the humorous bits tossed in too. Subbed :)
8:35 - The subtle big difference 😍😀 Wow.
you helped me make a touch controller with the same mechanics idea thanks a lot!.
Looks great! Much better than most of the cameras out there. Totally using this in my western RTS sim now!
btw, to anyone wanting a zoom with the scroll wheel, literaly just do this.
if (Input.GetAxis("Mouse ScrollWheel") > 0f)
{
newZoom += zoomAmount;
}
if (Input.GetAxis("Mouse ScrollWheel") < 0f)
{
newZoom -= zoomAmount;
}
Awesome video. Definitely gonna use some of this. Now I just gotta convert it to using Touch!
Thank you so much for this.
that was the best tutorial I ever watched👍
first minute in video THANK YOU FOR ADDRESSING THE FPS CAMERA ISSUE! that's as annoying as games not keeping wasd keys for strafe panning.
"your camera should be world relative."
Im gonna live by this
You are a hero, Sir.
Thank you for sharing the top on Field of View
This was very helpful. One thing I did find is
that I had to multiply my "movementSpeed" by Time.deltaTime when it got changed by the keyboard. If I didn't then it would have difference speeds at different framerates. I tested it at 10, 30, 60, and 300 FPS using Application.targetFramerate
Very useful guide! Thanks for sharing.
Your tutorials are very high quality. Subbed
so good, very nice, thanks!
great video m8, very usefull
Great job. Very smooth and easy
Thank you for this great tutorial :
Really helpful. So well explained. So well write. Thanks a lot!!
Really awesome tutorial ... clear, simple and great !!! thanks
Such a great video. So useful
amazingly detailed and well explained tutorial!
OMG this was perfect! you're an excellent tutor!
Absolutely amazing video, exactly the type of camera i was looking for. You should make a tycoon/simulation game asset for the store, I would buy it instantly :)
Very cool video mate, honestly you make some really informative stuff!
Just wondering, do you think you could do a video on creating a Camera Controller but for a 3rd Person 3D-Platformer? Would love to see one of those!
Nice video! Loved it!
But I have one question. How do I make a boundary around the scene, that the camera will stay inside? - Mostly just so the player doesn't move way out of the game.
Thank you very much! Now I can create a game with a good movement.
Love love love your videos! Can't wait to see your rpg series! (If that's in the works)
I really want to do turn based combat properly with items, camera events, etc.
Brilliant video!
One think that I wanted in my game is to have a smooth transition when you start following/focusing an game object.
Hint for anyone needing the same:
You can easily do that by setting the newPosition variable in HandleMovementInput() method to be equal to followTransform.position, like that:
if (Input.GetKey(KeyCode.F)) // I removed the F binding from zoom because I allow zoom only via mouse.
{
newPosition = followTransform.position;
}
hello, i tried doing what you said as it is a cool feature but it doesn't seem to work for me (maybe i'm too much of a beginner...), so could you explain a bit more please ? :D
我找到了好久,终于找到了,非常感谢
You were totally right about the camera perspective btw. Much better than orthographic.
Best tutorial ever.
Great video, very helpful. Wondererd if you'd consider updating it to the new Input System?
I'm having a problem with the mouse camera movement for panning and rotation. The panning shoots the camera off into oblivion and it doesn't necessarily go in the correct direction and the rotation is very jittery when holding it and when dragging it the screen freaks out until its let go and then it moves. This is a really good tutorial and I can't figure out what the problem is, maybe its framerates or something but I really need help with this. Keyboard controls work perfectly though.
Great video. Thank you
finally someone with some standards around here
PERFECT tutorial!
Brilliant tutorial - that resulting camera is excellent! Can you share a link to source code?
Very helpful thanks!
Thanks for this great video, it contains some good tips.