- Home /
Looking around without the entire body moving?
Well the question may be a little vague so let me clarify. My team and I are getting ready to work on a new game after having to put an older one on hold for a bit until things get sorted out. So I began running some tests in the editor, using the character controller assets, specifically the MouseLook, CharacterMovement, and FPSInputController. Now I've played around with first person before. I plan on writing my own scripts for first person, but I would like to know about how looking around actually works. I threw down a capsule, put the camera in it, assigned the scripts to the necessary objects and got it all working. Of course I did, they are pre written and work like a charm for simple tests. Now what puzzles me and I can't seem to figure out, is to prevent, when looking down, the entire capsule, or character model, from rotating it's entire body to look at the ground while not compromising it's ability to run in the direction the camera is facing. I've done some tests but to no avail. The best I could do was most likely obvious. Assign the mouse look scripts to something else, such as the camera alone, but obviously that would allow for you to look in any direction, but not move in that direction, as the Character is not facing that direction, just the camera, or so called head, (sphere).
TL:DR I need to be able to allow my capsule/character to be able to look down, without the entire body rotating and becoming horizontal, while not compromising the ability to move in the direction you are facing.
P.S I use C# if anyone has any code. I am not asking for someone to write code for me, I am simply asking how I would go about achieving what I have described.
just FYI if you are new, you are familiar with the "LookAt" command? see docs
Answer by LukaKotar · Feb 22, 2013 at 11:05 AM
The camera needs to be able to rotate up and down, and the whole character should rotate left and right. The mouse look script from standard assets should be a good example to how it should be written.
Put the script on the root of the character, and select 'Mouse X' from the menu in the inspector. Do the same for the camera, except set it to 'Mouse Y'.
That should be it.
Oh how could I be so blind?!?! Haha, that's great! thank you very very much for helping out! And while I didn't do it myself, I accidentally stumbled across the Prefab in the Character controller assets package. But had I tried it, it would have worked so thank you. Now comes the fun part, re-writing it in C# :D lol
Your answer
![](https://koobas.hobune.stream/wayback/20220613093151im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
C# Scripts don't work in Unity 3.5 any idea why? 1 Answer
C# Coding error 1 Answer
MonoDevelop Resizing 1 Answer