ThirdPersonHandler, RenControlEditor! They are impossible!

Ok, so I'm still trying to implement a character movement system. I have been trying all sorts. I got frustrated with my own efforts so I decided to turn back to the ThirdPersonHandler and I used the RenControlEditor to set parameters.



Problem is that when I try to implement the things I want, it all goes, well I shan't swear so, bad!  XD W is supposed to be forwards but it now goes in a clockwise circle OMG!  :lol:



All I want is a third person control implementation that has the following characteristics.


  • WASD movement for forwards/back/strafe
  • 3D rotation controlled by mouse, with limits on the vertical ascent (so u can look between angles +20 and -10)
  • Camera always behind player at a constant distance (player rotates with camera
  • Strafe goes in straight lines, not arcs



    Side note. What I have been thinking that I might like instead (in fact I would prefer it), is that a camera that is always at a static point behind the player (with relation to the player) but it can look up and down ie the center of rotation for the vertical rotation is the camera itself but have the horizontal rotation centered at the middle of the player. Like so…







    Trouble is I tried to dissect some code to find out how it worked and I did a pretty bad job. I would love to implement this myself but I have not really got any clues how to do it. Could someone please please please give me a shove in the right direction  :roll:



    Thanks



    Neilos

Ok so this is what I am thinking.



I will create a playerNode (Node for the player) attatched to the sceneNode (root node for the scene). Then create a camNode (node for my camera) and arttach as a child to playerNode. (This is done already I can see the player (box) and the camera is attached behind it offset by using the camNode)



I will set up an input handler for listening to key strokes and mouse movements. (Working on this now, any pointers would be great, I'm kinda learning it from scratch). WASD will be forward/back/strafe and mouse x movement will rotate the box (player) using playerNode.setLocalTranslation(blah) and playerNode.setLocalRotation(blah). Mouse y movement will change camera target (I think that I will just aim it at different points directly above the player at various heights rather than work out circle stuff, I think this will be easier, I'll see, the circle stuff may come before but dunno). Is there a method call for CameraNode to set a target? Otherwise I think camNode.setLocalRotation(blah) would do the job, just have to do a bit more math.



Then I think that the camNode will always be at the same point relative to the player with different angles of view (up and down, centered at the camera position).



Can someone tell me please if I am on the right track? I need help with the InputHandler as well and I need to research how exactly to call the updates that I need, if someone has a short explanation I'd be grateful?



Thanks



Neilos

Sounds you are on the right track, i also never got ThirdPersonHandler behave how i liked to, you can look at it as an exampe for your own implementation.



node.lookAt() is a nice convenient Method, to rotate the cameraNode the way you want.



I also went that route to create a simple chasecam here

Hi!

I was actually playing with this a lot for my project.

You really shouldn't use ThirdPersonHandler. Just create a chase camera and bind keyboard buttons to actions. In my project I use physics for moving, so I will not paste this code, but I can paste code for decent chase camera, which I use. Try to play a little with its values… :slight_smile:


   private void initCam()
   {
      ChaseCamera chaseCam = new ChaseCamera(DisplaySystem.getDisplaySystem().getRenderer().getCamera(), playerModel);
      chaseCam.setEnableSpring(true);
      //chaseCam.setDampingK(100);
      //chaseCam.setSpringK(100);
      chaseCam.setStayBehindTarget(true);
      chaseCam.getMouseLook().setMinAscent(0.1f);
      chaseCam.getMouseLook().setMaxAscent(0.8f);
      chaseCam.setMinDistance(10);
      chaseCam.setMaxDistance(25);
      chaseCam.getMouseLook().setMinRollOut(10);
      chaseCam.getMouseLook().setMaxRollOut(25);
      chaseCam.getMouseLook().setMouseRollMultiplier(2);
      chaseCam.getMouseLook().setSpeed(0.5f);
      chaseCam.setTargetOffset(new Vector3f(0, 3, 0));
   }

Hi, thanks for the example code. at the moment I have made my own ChaseCam class and I am using this. I will look into ChaseCamera more soon as I think it will be better than what I have got going but I got something that does what I want for this project so it suits me for now.  I will definitely try your code soon.



ThirdPersonHandler is really sooo bad. It could be good if changed slightly but at its current state I dislike it. Why has no one changed it? Because there is so many people hating it right now lolz. I would if I could but I can't. Just interested why everyone hates it but leaves it, surely it is pretty redundant?