Camera inside head


I’m trying to create a FPS game… It works fine so far,
but I placed the camera inside the head, works fine, but I can see the insides of my head. When I try to place the camera just in front of the head works fine, but when I animate my head I see it again.

How can I prevent that?

in FPS’s the own player model usualy isn’t displayed at all.
usualy the model only consists of the 2 arms. sometimes feet or chest.

well… not an option, because when the player presses a key it switches to Third Person mode.

Just use



when the player switches from first to third and back again.

Fine, but then I don’t see the hands of the player anymore…

Just hide the head, then. Use the “find” operator on the actor to obtain a pointer to the head. The only tricky part is that you have to design and build your model so that the head is a separate piece. The details are in this section: … of_a_Model

Or, here’s another approach: attach the camera to the model’s head, using exposeJoint. There’s a sample program that shows how to attach a teapot or sword or banana to a character’s hand. This is basically the same. Of course, this might produce some unpleasant wobbling. It might be better to just hide the head.

In the tutorial Feature-Tutorials–Joint-Manipulation in Panda3D’s samples dir, you see how to attach an object to the hand of a model. Perhaps you could do something similar: attach a camera to the head of your model.

@Laurens: That’s just what I’m doing… I attached it to the head but I can see the insides of the head now…

I tried exposeJoint first… well… the head still shows up.
No error messages, the joint exists…
I tried the find(, that works, after I used egg-optchar.
But, after I used egg-optchar it can’t find the other joints…

self.myNeck = self.myplayer.controlJoint(None, 'modelRoot', 'Neck')
        self.rightHand = self.myplayer.exposeJoint(None, 'modelRoot', 'RightHand')
        self.myFace = self.myplayer.find("**/Face")

Face is found and the Neck is found, but the RightHand gives an error right now… Before I called egg-optchar there was no problem…
Now the weapons the player wields are hovering on the ground…

It works fine, but… it can’t find any joints anymore.
the self.myplayer.find("**/face") works,
but not the self.myplayer.controlJoints("RightHand")

egg-optchar removes joint information that you didn’t explicitly request be retained from the model file for efficiency.

I’d double-check that you requested the joints you need to access at runtime be kept in the file by using egg-optchar’s ‘-keep’ option.

Best of luck!

… why not simply using 2 models and switch between them ,always hiding one?
less effort,less code, and allows to have high-detail 1st person models while keeping 3rd person model less detailed to save performance.

anyone ever thought of just adjusting the near plane of the camera?

Anyway, I don’t see how you could do this wrong.

Just attach the camera to the model, place it in a fixed position (relative to the model of course) thats in front of your head and you’re done.
If you say you’ll see the head again when you rotate your view then it’s because you did something wrong, like moving the camera around instead of the model.

I did the same thing you’re trying to do for my First Person Space Shooter.
I reparented the camera to my player model. It’s perfectly moving with the object, I don’t see any artifacts from my model (due to proper camera placing) and I have a thrid person view, too.
Anyway, for performance purpose in a normal FPS game I wouldn’t recommend displaying the whole actor model while in first person view.
make two models. One actor model for third person view and one hands/weapon only model for first person view. Then use the show/hide commands on those models depending on the view your player uses.

Thanks Legion and mtomczak, just what I need! :slight_smile:
It works now :wink: