Hello there, total beginner trying to get my feet wet. I think I have some “old-school” or “different” expectations on how to create a player with a first person perspective camera and attach input to it.
I want to create a simple car game where every player sits inside a car and steers it with some input buttons. The cars will have custom behavior / physics eventually. I thought of creating each player in an object hierarchy like this:
- Collision body
- Visible mesh (hidden for current player or replaced with cockpit / HUD mesh)
- Inside Camera (active only for local player)
That way, moving and coding the behavior of the collision body would move the visible mesh and camera in sync.
I tried the existing cameras in Babylon.js which did not really work out:
Camera: Thought this simple base class would suffice, but the view does not change when I move the mesh I set as its parent, nor when I directly set the camera’s position.
FlyCamera: These ones were the only ones with collision properties like
checkCollisions. Those surprised me in being specific to a camera. I’m not sure how I would allow opponent players participate in physics then, as they would not have a camera at all.
FollowCamera: Followed my mesh at least, but had too many “extra features” like interpolation / smoothing, and even trying to disable all those by changing its properties like
radiusto 0 still caused it behave weird eventually. This is the only attempt I kept: Babylon.js Playground
Am I on the wrong path here? Do I have to write my own Camera class from scratch to attach it to an object like that? Do I need to use a physics library for physics on other players?