We are trying out best to make a well developed first person controller for our game and we need some help. We tried several times using various controllers across the internet but though they are good pieces of coding I never quite find them to be polished enough to be fully game ready.
Though I doubt I could do much better. (not exactly coding savy) I would like to attempt my own first person controller
specifically something almost interstellar marines inspired. A full body with the camera itself mounted where the head should be. Where the movement is directly influenced by the animation. (making it more immersive in theory)
I’ve made a full body model and it has been given a simple rig for animation. Ive started animating simple locomotion animations (Idle, sprinting, jogging) but even the simplest things seem to escape me. I was thinking if I made the camera a child of the head’s main bone then I could use the head look controller to make the gun point at the mouse (as well giving it added fluidity that other First person controllers seem to lack) I cant seem to grasp even setting up a head look controller.
I’m sorry for the long long post but I need help, we are a couple of amateurs looking to get our project off the ground and with a first person controller being a BIG part of game play I find it to be a good place to start. So please any advice you can give would be most helpful. I don’t even know where to begin and would love a push in the right direction.
Where did you get stuck? Are you using the head look script from the Head Look Controller sample project or something else?
As a first pass at this, I’d probably parent the camera as you describe, then apply the default MouseLook controller from the standard assets. That should be enough to give you a feel for how the camera view interacts with your character animations.
I’m not sure I’d even look at the head-look controller, since the head itself isn’t going to be visible. It should be enough to control the orientation of the camera itself, as you would in any 1st person setup.
Much of the complexity in that script is about managing how the head movement propagates to the rest of the body (e.g. into the neck and spine) or doesn’t propagate (e.g. so the head movement doesn’t disrupt where the character appears to be pointing its weapon).
Again, I question the value of adding all that sophistication to the animation of a character that isn’t visible. Then again, I don’t know exactly what you’re trying to achieve in terms of camera response; perhaps you want or need those subtleties to achieve it.
In addition to the simplified approach I outlined above for setting up the character in your game, you can also try modifying the Head Look Controller demo so the camera is attached the way you plan on doing it, and see what the results look like. You can then test with head look enabled/disabled (by turning the script on and off). That would tell you if you need the complexity, without the need to understand how to implement it in your own game first.
The point of having full body animation is to give the ultimate first person immersion. If the general movement of the character is propelled by actual animation rather then just coding it will feel much more fluid and real. You can code the up and down bounce of the player taking step after step, or you can feel it in the animation. Which is what I hope to achieve.
The head look controller is simply a means to an end. I’m trying to get the hands holding the weapon to always remain in the center of the screen where it should be. So that the camera may look around and the gun can move appropriately. I was hoping the head look controller could provide such movement by me simply making it so the spine moved as the head would, following its target, in this case the mouse.
Again I am not especially coding savy. (probably the least knowledgeable on it in my group.) I’m simply inspired to learn in order to get this done. So if you could explain to me simply what I should do it would be great. I just need a point in the right direction.
You can use a raycast from the camera to get the point in the game scene which is currently under the mouse (check out this thread for a code example). When you have that point, you can make an object look at it using transform.LookAt. The individual bones in an object are accessed as though they were child objects of the main parent. You can access them using transform.Find (the manual page shows the “pathname” notation you can use to identify a bone). Basically, you just need to access the bone for the head and use transform.LookAt to point the head at the point obtained from the raycast.