-
Notifications
You must be signed in to change notification settings - Fork 90
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Third-person camera support? #54
Comments
Hey, thanks for looking at the library! Third person camera can mean a couple of things, but did you see The way it currently works is, there's an empty mesh called But it's meant to be an optional default implementation - a game with particular needs can in principle make a new camera and have it move however, and tell Babylon to render with that one instead of the default one. I haven't done this personally, so there might be wrinkles though. Let me know if that's what you're looking for.. |
Oh my goodness, I can't believe I didn't figure this out. Yes, this is exactly what I was wanting! Thank you so much! ❤️ |
Ah good... the property could probably be better named. BTW there's also a camera zoom speed property, for how fast the camera tweens to the desired zoom level. But the default behavior is that the library also raycasts backwards from the player's head each frame looking for obstructions, and limits the zoom level if it encounters solid voxels. Hope that helps, thanks for trying things out! |
As far as I know,
noa
doesn't support this, so I tried to implement it myself. You can see what little progress I made on my fork: https://github.com/queer/noa. My solution was basically:thirdPerson
optionBABYLON.FollowCamera
instead ofBABYLON.FreeCamera
queer@43cf935#diff-b749cc3d9f54b036169c5f6667c372f1R80_camera.rotationOffset = 180
to the_camera
inEngine.rendering
, ex queer@43cf935#diff-3ea7e95fe221c10d64716282fd60defdR187At this point, most everything works correctly execpt for raycasting to get the block the camera is pointing at. There are a few things like camera min/max angles not being exactly correct, but that was less-important than raycasting to me.
After digging into it more, the problem appears to be that
Engine.getCameraVector()
seemingly ends up being perpendicular to the direction the camera itself is facing in, makingEngine.pick()
return incorrect results. I tried to fix this by using the camera pitch/yaw (fromEngine.rendering.getCameraRotation()
) to construct a unit vector that faces in the correct direction, but that didn't produce the correct result either; it just gave me a vector that was still facing in the wrong direction, but with a different perpendicularity relative to the camera's actual direction. The attempts at that can be seen here: queer@43cf935#diff-1fdf421c05c1140f6d71444ea2b27638R397 (including some remnants of probably-misguided attempts at transforming the rotations / unit vector)At this point I'm pretty lost as to what can be done to implement this correctly. I was wanting to open a PR if I managed to implement this successfully, but it doesn't seem like it's likely to happen.
The text was updated successfully, but these errors were encountered: