[Solved] Mouse movement with MouseAxisTrigger feels unresponsive

I am trying to get the camera to move in different ways when using when moving the mouse.

The way I’m catching the movement in the X-axis doing it is with

[java]inputManager.addMapping(“RotateLeft”, new MouseAxisTrigger(MouseInput.AXIS_X, true));[/java]

together with an inputManager and the mapping that follows.

The mapping looks like this:

[java]if(rotation) {

if(name.equals(“RotateLeft”)) {

Vector3f camDir = cam.getDirection().clone().multLocal(0.8f);

if(cam.clone().getLocation().addLocal(camDir.mult(camZoomSpeed)).y > 0) {

cam.setLocation(cam.getLocation().addLocal(camDir.mult(camZoomSpeed)));

}

}[/java]

(Bear in mind that this mapping is not actually rotating anything yet, it’s just a dummy with code I already have)

It works, the problem is however that it feels like I have to move the mouse very fast before it seems to catch the movement.

Is there a way to get it to be more sensitivity, or am I just doing it wrong?



Thanks :slight_smile:

I don’t see any code that accounts for framerate except you multiply camZoomSpeed with tpf somehow, else just increase camZoomSpeed?

Well the problem is that even if I would change the code to

[java]if(rotation) {

if(name.equals("RotateLeft")) {

System.out.println("Moving mouse");

}

}[/java]

It would return Moving mouse only when I move the mouse fast.

what is “rotation”? you only need to account for the values delivered, really.

Should perhaps have posted without the boolean, “rotation” is just a boolean to check if I’m supposed to rotate, meaning if I have the correct button pressed to rotate.

Something else is wrong in code we don’t see.



If the mouse moves in a frame even a little then you get notified. I get a spew of notifications if I barely even bump the mouse… so something else is wrong.

Hmmm…

I’ll send more of the code then :slight_smile:

[java]private void initKeys()

{

inputManager.addMapping(“testing”, new MouseAxisTrigger(MouseInput.AXIS_X, true));

inputManager.addListener(buttonActionListener, “testing”);

}

int testing = 0;

private ActionListener buttonActionListener = new ActionListener()

{

public void onAction(String name, boolean isPressed, float tpf)

{

if(name.equals(“testing”)) {

testing += 1;

System.out.println(testing);

}

}[/java]

The reason I use the integer is just to really see when it catches new movement.

Use an AnalogListener for mouse motion.

http://hub.jmonkeyengine.org/javadoc/com/jme3/input/controls/AnalogListener.html

Wow thanks, I even got the javadoc handed to me on a plate :smiley:

:slight_smile: Some of us have it open everywhere. :slight_smile: