Heads following player

Community Forums/Showcase/Heads following player

Drak(Posted 2010) [#1]
I've been working on getting this just right over that last few days and have finally got it working the way I want. Basically what I wanted was a seperate head mesh from the body mesh. The body meshes are still animated the same way, and the head is controlled elsewhere. I can now get my npcs to look at different objects, or the player, or whatever, and still maintain their original animations.

This has opened up a wealth of customization now as I can put different heads on the body mesh, instead of retexturing a whole character. I could have hair, hoods(as seen here), helmets, hats, etc. All while not having to animate different meshes.

Heads cannot turn beyond a certain degree from the npcs body, as shown in the picture below. The npc on the right cannot turn his head any further, although he is still trying to face the player. The other two can, and will look at the player so long as he is in "range".

I know this has been done before but I feel pretty good about coding my own functions for this. I also found out it's not quite as straightforward as it seems.

Here is an example:



FBEpyon(Posted 2010) [#2]
Thats very nice, I like it alot, and I'm glad to here you got it working, thats always best.


grindalf(Posted 2010) [#3]
I did this once, it was quite easy apart from when they went out of range and the head jerked back to straight forward :(

Anyway, I like the look of this game. Nice work :D


Drak(Posted 2010) [#4]

when they went out of range and the head jerked back to straight forward :(



I've got a simple solution to that using the orientation of the parent body and the orientation of the child head, when the player is out of range the head slowly turns back in line with the body.


puki(Posted 2010) [#5]
Yeh, I've done this before before - it does look cool when you do it for the first time - it actually almost makes them seem like they have some kind of AI.

You can do the eyes too - even with premaded meshes with eyes. I just put little textured spheres over their eyes - you have to faff about to get the sphere inside the head, but just poking out enough to cover the default eye - then you can make them move their eyes too. The beauty of this is it is a LOD system, so you only show the eyes when the sucker is close.


Drak(Posted 2010) [#6]
The eyes are actually a 3d mesh. They're a turned-on-the-side half sphere. The bad thing is I grouped them both as 1 object when I made them in the editor. So if I were to turn them, one would pop out of the head while the other would sink into it :)

I don't need animated eyes anyway. All I can do is swap textures for a few frames to make it look like they're blinking, though.