Changing Value of ASDW controls (FlyCam)

Hey guys,



I am trying to modify the value of the controls ASDW located in flycam. They’re too fast for me and I want to create some sort of a pre-defined variable that would be the value of these control that is passed to onAnalog() or onAction() in order to have a better control over the speed of the camera movement.



whats the best way to achieve this?



thanks

Here it goes: http://hub.jmonkeyengine.org/javadoc/com/jme3/input/FlyByCamera.html#setMoveSpeed(float)

Doesn’t flycam already have a set speed function?

sorry should have been more specific… I am trying to increase decrease with buttons so by pressing let’s say the + button increase the speed. I already tried using: currentCamera.setMoveSpeed(value-0.01f); and that didn’t work. Debugging it, whether I increase or decrease, the value is a float number that is not constant.

It should work. However, the Move Speed should be higher to be noticeable, I think. Try and drastically increase it (say, 100) and let us know what happens.

but even when I increase it by 100 and print each time, here’s the trace of speed increasing:



[java]speeed increased to 0.0017270469

speeed increased to 0.002251833

speeed increased to 0.001629532

speeed increased to 0.00150892

speeed increased to 0.0039994097

speeed increased to 0.001652628

speeed increased to 0.0015929639

speeed increased to 0.001524318

speeed increased to 0.001598096

speeed increased to 0.00161221

speeed increased to 0.0014864659

speeed increased to 0.0015365069

speeed increased to 0.00168278

speeed increased to 0.004900143

speeed increased to 0.0015429229

speeed increased to 0.001615417

speeed increased to 0.0015583199

speeed increased to 0.0016628919

speeed increased to 0.001673157

speeed increased to 0.0015480559

speeed increased to 0.001606436[/java]



it’s not always increasing…

@nightwolf911 said:
sorry should have been more specific... I am trying to increase decrease with buttons so by pressing let's say the + button increase the speed. I already tried using: currentCamera.setMoveSpeed(value-0.01f); and that didn't work. Debugging it, whether I increase or decrease, the value is a float number that is not constant.


Show use the real code. The line you quote is setting the move speed to be the same every time... it will only vary slightly by tpf since value for a key is the equivalent to tpf.

Why don’t you just do this?



currentCamera.setMoveSpeed(currentCamera.getMoveSpeed()-0.01f);

@memonick said:
Why don't you just do this?

currentCamera.setMoveSpeed(currentCamera.getMoveSpeed()-0.01f);


Then if your frame rate is slow then your change in speed will be slow and if your frame rate is fast then your change in speed will be fast.

Better to do currentCamera.getMoveSpeed() - someAcceleration * value

Where someAcceleration is the amount of move speed change per second that is desired.

how about this:



here’s the trace

[java]

move speed increased to 0.001736671

move speed increased to 0.003240458

move speed increased to 0.001766823

move speed increased to 0.0019195119

move speed increased to 0.001880377

move speed increased to 0.0018412429

move speed increased to 0.001804033

move speed increased to 0.001855357

move speed increased to 0.0018373929

move speed increased to 0.0046993387

move speed increased to 0.001824562

move speed increased to 0.0019438909

move speed increased to 0.0017078

move speed increased to 0.0018713949

move speed increased to 0.0020414048

move speed increased to 0.0017154999

move speed increased to 0.0017713129

move speed increased to 0.005294695

move speed increased to 0.001693686

move speed increased to 0.0018611309

move speed increased to 0.0018521489

move speed increased to 0.002027933

move speed increased to 0.0015711499

move speed increased to 0.001721915

move speed increased to 0.004344563

move speed increased to 0.001831619

move speed increased to 0.001828412

move speed increased to 0.0019130959

move speed increased to 0.0017674649

move speed increased to 0.0018239199

[/java]

That should be multiplied by the tpf, not value. You should use ActionListener if your desire is just to know if the button is pressed or not.

still :S it results in a very similar trace :S



edit:



even when I do something like currentCamera.setMoveSpeed(20); and put different numbers, same thing… I don’t get it.



btw currentCamera is an instance of a class MainCamera that I created (extends flycam), issue is definitely not from that class as it works in other controls just fine.

If you set move speed to 20 and it isn’t changing then either something else in your code is setting it back or you aren’t setting the same camera instance.



Only you can sort this out with a debugger… unless you can shrink it to a small test case.



Do note: for an analog key listener tpf and value should be identical… but 0.01 * value or 0.01 * tpf is going to be super small. It means that speed only increases by 0.01 every second.

…though I’ll admit, the whole “command manager” thing leaves a lot of guesswork on our part. Who knows what things it might be doing and I’m not sure why this isn’t registered with the input manager directly.

you were right I was totaly changing another instance…



thanks