Creating a first person camera

Hello! Can someone show me how to make a fully working first person camera which also has physics applied using the Bullet physics engine?

Any code snippets would be appreciated.

It should just be the same as making a character move around, but with the camera placed at the location of the character’s head, I believe.

The only real nuance to it is that you may want to adjust the near-plane of the camera in order to prevent obstacles very near to the camera from being clipped away. I think that I’ve seen advice regarding this on the forums before, so some searching should, I think, turn up somewhat.

(“The only real nuance” unless you intend to apply head-bob too, of course–but I discourage you from doing so, as I gather that a fair few people dislike that.)

I don’t understand the camera. It doesn’t get positioned properly most of the time.

Can I have a code snippet?

Remember that the camera is a NodePath like any other; you should be able to parent and place it in just the same way.

What happens when you try to place it?

As to a code-snippet, it might look something like this:

# Presume that you have a NodePath called "self.myCharacterNodePath"
# that controls your character.
# If your "myCharacterNodePath" has its origin at floor-height,
# we'll want to move the camera upwards to about head-height

And that’s it.

What happens is that when I set the Z to 10, it is too low. So I set it to 100, it is still where it was when it was at 10.

And may I ask, what is the difference between and

Have you disabled the default camera-controls?

Otherwise, perhaps if I saw an excerpt of your setup I might be able to spot what’s going wrong.

Honestly, I don’t recall offhand. ^^;

There’s likely to be an answer somewhere on the forum, however, if you do a search!

Please see this post:

EDIT: is a child of

1 Like

I’ve replied in that thread.