- Home /
RTS type of camera
Hay, i was wondering how i would go about creating an RTS type of camera system. Where you would use the mouse to rotate a character and use WASD control scheme to move forwards, backs and sidestep. The camera would be fixed on the player, and wouldn't rotate.
Answer by digitalConundrum · Mar 02, 2011 at 12:56 AM
The simplest way I can think of to do this would be to create the camera as a child of your unit. Since you want it to be attached to the unit, I'm guessing that you didn't really mean that you want an RTS camera(as those are usually unattached and give a birds-eye view. I'm going to go along with the assumption that you meant RPG.
As you don't want the camera itself to rotate it seems the best choice would be to attach it to your unit and position it as desired. Then you could add a collider to the camera (box or sphere most likely) and write a script to move the camera closer to the unit if the camera collides with something..say if your unit is backed up against a wall...and to move it back to the original position when the collider is no longer in contact with anything.
As for moving using wasd and the mouse...there is a character controller built into Unity if you don't mind allocating the resources to using it...otherwise its up to you to write your own movement script.
Take a look at the scripting reference, It's wonderfully done and is the most helpful documentation I've ever used.
Definitely look at using dynamic parenting in code so that you can quickly move the camera between units without having to duplicate your camera control code.
Your answer
Follow this Question
Related Questions
Logical Camera errors... 1 Answer
How to make my camera only rotate on middle mouse click? 1 Answer
Rotating a camera that has MouseLook.cs attached 0 Answers
Camera Rotation Tips 1 Answer
Make camera rotate don't stop 1 Answer