(Solved) first person style camera move but only when mouse button pressed

im using the framework of the DebugGameState which i copied into my own CustonDebugGameState, i havent changed anything in it yet, but what i would like to do is change it so it uses the firstperson handler, but only moves the camera when the right mouse button is held down. the keyboard bindings should still function regardless of the state of the mouse buttons.



how would i go about modifying the DebugGameState to support this?

What you probably want to look at is the PROP_MOUSEBUTTON_FOR_LOOKING property of the ThirdPersonMouseLook class.



If you set this to 1 instead of the default -1 then it will only allow the camera to move on mouse movement when the right button is held down.



Search for usage of ThirdPersonMouseLook in the JmeTest packages, in particular in the Flag Rush Tutorial since it uses a ChaseCamera.



Hope that helps!

create ur own chasecamera which first person handler. the mouselook in the chasecamera class built in jme has only thirdperson handler.



its not a big deal, u shouldnt have any problems changing it.



then do chasecamera.getmouselook().setlookmousebutton(1);



1 is the int for right mouse button, 0 is the left one. :smiley:

neakor said:

create ur own chasecamera which first person handler. the mouselook in the chasecamera class built in jme has only thirdperson handler.

its not a big deal, u shouldnt have any problems changing it.

then do chasecamera.getmouselook().setlookmousebutton(1);

1 is the int for right mouse button, 0 is the left one. :D


would you be able to provide an example of what that would look like? i can't seem to figure it out the way you are describing it.
Atmospherian said:

neakor said:

create ur own chasecamera which first person handler. the mouselook in the chasecamera class built in jme has only thirdperson handler.

its not a big deal, u shouldnt have any problems changing it.

then do chasecamera.getmouselook().setlookmousebutton(1);

1 is the int for right mouse button, 0 is the left one. :D


would you be able to provide an example of what that would look like? i can't seem to figure it out the way you are describing it.


check out the chasecamera class in jme.input.  it has a thirdpersonmouselook varible which extends mouseinputaction.

u can create ur own firstpersonmouselook class and put it into ur own chasecamera class.

i think maybe theres a way to get around creating new classes but just using the built in chasecamera class with thirdpersonmouselook.

lets say, maybe set the targetoff set to be really small, and set min distance and max distance to be really small as well. im not really sure about this, coz in my game im using thirdperson mouse loook. but it shouldnt be really hard. just test it out.

good luck :D

Check out  jmetest.input.TestThirdPersonController  for the third person controller.  Here's my example codeā€¦it may be a bit outdated and I haven't tried it recently (did it last summer), but it may help.  Obviously the important line in the second one:


HashMap camProps = new HashMap(1);
camProps.put(ThirdPersonMouseLook.PROP_MOUSEBUTTON_FOR_LOOKING, new Integer(1));
Vector3f targetOffset = new Vector3f();
targetOffset.y = ((BoundingBox) m_character.getWorldBound()).yExtent * 1.5f;
chaser = new ChaseCamera(cam, m_character,camProps);
chaser.setTargetOffset(targetOffset);



Enjoy!

ok so here is the solution i came up with:



first, a custom mouse look class that uses mouse event listeners.


public class CustomMouseLook extends MouseInputAction {