Move() with tpf


#1

Hello!



I’ve searched this forum about working with the tpf Value. Most of the times the answer was “just multiply your value with the tpf”.

But still, my movements are framerate dependant. The lower the Framerate is, the faster my Quad moves. How can I prevent this? I would like to have a smooth moving effect.



Thanks in Advance!



[java] if (name.equals(“Right”)) {

testGeom.move(2.5ftpf,0,0);

}

else if (name.equals(“Left”)) {

testGeom.move(-2.5f
tpf,0,0);

}

else if (name.equals(“Up”)) {

testGeom.move(0,2.5ftpf,0);

}

else if (name.equals(“Down”)) {

testGeom.move(0,-2.5f
tpf,0);

} [/java]


#2

I would like to have a smooth moving effect.


Whether or not the movement is smooth is entirely frame rate dependent... Your frame rate is going to determine whether your graphics look smooth or choppy...

As to why your framerate is effecting the speed of your cube i don't know, the code you have supplied there should fix this issue
http://hub.jmonkeyengine.org/wiki/doku.php/jme3:beginner:hello_main_event_loop?s[]=ticks&s[]=per&s[]=frame

#3

try to enable vsync or or to fix the frame rate to a constant low value (like 60 or 30). You’ll have a lot less frame rate variation.


#4

@kbender88

This is exactly what I was doing. But thanks for the suggestion!



@nehon

Hmm looks like I can’t expect to get the same behavior with 4000 and 60fps.

The speed difference is unnoticable between 60 and 24fps. I guess i’ll just limit the fps to 60 or maybe 120, so I don’t “alienate” the 120hz-Screen users.



Thanks!


#5

sorry too many times i wanted to post but couldn’t cus i said i wouldn’t on my main account so i made a new one ^^



solution:

[java]public void onAnalog(String name, float value, float tpf) {[/java]

use value instead of tpf


#6
@wezrule2 said:
sorry too many times i wanted to post but couldn't cus i said i wouldn't on my main account so i made a new one ^^

lol ^^ nice catch as well ;)

#7

@wezrule2

That was the first thing I tried, but then it’s faster with high FPS.


#8

Anyway, tpf works fine in all jme games but yours. Its your code, maybe you do tpf++ or something.


#9

Yeeh, I’m using tpf and I get constant movement at everything from 3000 fps to 200fps.


#10

You’ll have problems with TPF if you alt tab, just warning. If you spend like 10 seconds with the game paused on alt tab, you’ll have a unexpected behavior.


#11

I have te same problem with same code


#12

Your code looks fine from here.


#13

Hehehe :smiley: nice one :smiley: , but i dont want to bother every time some thing aint works , soo i try to fix it my self for now .