AI jumping. Testing and help.

For questions about using Classic.

Post » Sun Dec 05, 2010 8:18 pm

I did some tests to shed some light on the cause.

The max y position reached when jumping can be calculated with the following formula:
[code:1lcbmjqd]StartingY - (jumpStrength^2)/(2 * gravity)[/code:1lcbmjqd]
It seems that the platform behavior goes about 20 pixels higher than what is calculated when running 60fps.
I switched to unlimited framerate and it was only higher by 2 pixels on my computer.

The platform behavior seems to have a more accurate jump height with higher framerates, and a less accurate one with lower framerates.

Here's my test of the platform movements jump height with two other methods of computing motion.
[url:1lcbmjqd]http://dl.dropbox.com/u/5426011/examples3/JumpTest.cap[/url:1lcbmjqd] made in 0.99.96

A workaround could be to set gravity to zero and manually change the vertical velocity every tick with a more accurate method like Verlet.

Hope some of this is helpful.
B
79
S
24
G
53
Posts: 4,728
Reputation: 40,219

Post » Sun Dec 05, 2010 9:29 pm

Interesting topic. I have a 60 Hz display.

I tried the original, and it performed poorly for me most of the time.

In the second version, success rates seemed higher, but still not consistent.

The Timedelta override version was perfect every time for me.

The other thing that I noticed was that the 2nd and 3rd versions were a bit choppy on the side-scrolling.
B
3
S
2
G
2
Posts: 187
Reputation: 1,449

Post » Mon Dec 06, 2010 3:09 pm

The side-scrolling issues is nothing to worry about. I haven't cared much about the camera.

So it seems like the problems are caused by the irregularity in the platform movement caused by timedelta then. Thank you very much for your post ROJO, very helpful. I'll try to make a version using Verlet.

Another thing i thought about is if it's possible to use the timedelta expression in the jump-event to ajust the height for the platform movement. Don't really know how since i don't understand exactly how it works, but it would be great if it was possible.
B
8
S
2
G
5
Posts: 744
Reputation: 3,288

Post » Thu Dec 09, 2010 4:18 pm

So ROJO, i reworked your .cap to make the verlet thing move through a loop for better collision detection, but for some reason it jumps a bit higher, even though it (as far as i can tell) should be exactly the same.

http://dl.dropbox.com/u/930918/Jumptester.cap

At first i tried to make it like:

Always
-run loop "up" ceil(distance) times.
-set Y: Y+(distance-ceil(distance))

Something like that, but it had some problems with floats that i couldn't figure out how to solve, so i used the workaround that is in the .cap right now. I'm not really happy with it though. I don't like the unexplained extra height, and I get the feeling it could be made in a more efficient way.

Anyways, I'm going to implement it into my AI thingy and see how it works out.
B
8
S
2
G
5
Posts: 744
Reputation: 3,288

Post » Thu Dec 09, 2010 6:13 pm

It's actually less height. You need to change the order of actions so that the variable vy is changed after the object is moved instead of before. Then the jump will be the same as the calculated.
B
79
S
24
G
53
Posts: 4,728
Reputation: 40,219

Post » Thu Dec 09, 2010 7:18 pm

Doh.. i gotta learn to avoid getting tunnel vision when i spend too much time on the same task. This situation is way to familiar.

Thanks.
B
8
S
2
G
5
Posts: 744
Reputation: 3,288

Previous

Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 5 guests