I just started playing arround with 3D in libgdx. I already know how to draw basic Model, and I tried to play arround using CameraController. Now I want to create FirstPersonCameraor FirstPersonCameraController. I was thinking about expanding PerspectiveCameraand adding to it MyMovingObject target. MyMovingObjectwill contain x, y, z positionwhere yis a constant value, so I can’t move up/downat the moment. So my movement is significant in 2D. MyMovingObjectalso save left/right rotationrequired for moving direction/ xSpeed, zSpeed. But Playerit should also be able to look up and down, and this up / down rotation is not required for MyMovingObject, as it changes its appearance and other properties. So I'm not sure if I will go right.
I want to be able to move forward, left, right, back, using W,A,S,Dand rotate left and right with the mouse. I also want to look up and down with the mouse, as in most games First Person.
Should I use a different method without creating my own camera, expanding PerspectiveCamera? Or is this approach good, and I just need to keep the up / down rotation in MyMovingObject, as well, if it is only necessary for presentation?
Or would it be better to control the camera with W,A,S,D and mouseand update the position MyMovingObjectdepending on the camera position and rotation?
I hope you understand what I mean. This seems to be a little hard to explain (at least for me).
EDIT: Now I use Vector3 direction, Vector3 positionand Vector3 sizefor their NPC and the player. I calculate the speed by doing: xSpeed = direction.x / (direction.x + direction.z) * speed;the same for zSpeed. By doing this, I "filter" the y value from it, and get only a percentage of x and y. The only problem is that when I look straight up, xand zare 0. I could fix this using a UpVecotrthat turns when I do a "turn on a step". But how do I turn it? I need to rotate it around a side vector. Thanks
: (. ), " ". : if (direction.y < 0.9 && angle > 1) doPitchRotation(); else if (direction.y > -0.9 && angle < 1) doPitchRotation();, , , , , -0,9 y, . : - 0,9, Y, , . , ? Y-Axis , , ?
EDIT: . , upVector . Y- . upVector.