Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Make Physics Jump Quicker

Author
Message
James Tighe
9
Years of Service
User Offline
Joined: 22nd Jul 2015
Location: Portsmouth, Hampshire, UK
Posted: 28th Jul 2015 23:38
Hi Guys,

I have an issue where I have a jumping sprite using physics.

When the z key is press I use a SetSpritePhysicsVelocity to set the Y velocity to a negative number and make the sprite jump.

When the key is release it changes the Y velocity to a positive number to increase the speed of the fall as I want a quick jump animation.

I am having problems with the upward jump part. No matter what I try the jump never increases in speed. I what the jump to be fast and currently it is really floaty It is weird as I can speed up the descent.

Example code is below



I have tried using SetSpritePhysicsImpulse but I cannot get it to move as fast as I need.

Thanks in advance

James

Brian Kuh: If anybody wants to see, there's a Donkey Kong kill screen coming up.
crazy_asian
9
Years of Service
User Offline
Joined: 13th Jul 2015
Location:
Posted: 29th Jul 2015 00:59
Hi James,

When I plugged in your jump code, and tweaked iy#, and it worked for me. I wonder if the problem might be your 'not jumping' code?

In case it helps, here's what I use for 'pushing' my player down when I release my jump key:



That may or may not help you, but it seems to work for me!

Good luck.

Tim
James Tighe
9
Years of Service
User Offline
Joined: 22nd Jul 2015
Location: Portsmouth, Hampshire, UK
Posted: 30th Jul 2015 15:11
Hi crazy_asian,

Weirdly when I copied the code into a blank project it worked and the jump is not longer floaty.

Therefore it must as you hinted be the 'not jumping' code. It clearly is doing something odd.

I'll go through it and find the offending line! lol

Thanks

Brian Kuh: If anybody wants to see, there's a Donkey Kong kill screen coming up.
Funnell7
13
Years of Service
User Offline
Joined: 8th Sep 2011
Location: UK, England
Posted: 30th Jul 2015 16:51
When using the Physics engine, the first thing I do is change the Physics Scale to 0.05 (I find the default value to be too limiting)... For my platform game, I've also changed the gravity to 1000, thus producing a much faster fall to ground (naturally you have to increase the jump force, but I found with this combination I was able to get it to feel just about right)...

Using AppGameKit V2 Tier 1
JohnStabler
AGK Bronze Backer
11
Years of Service
User Offline
Joined: 16th Aug 2013
Location: Cardiff, Wales, UK
Posted: 30th Jul 2015 16:55
Funnell7 makes an important general point. The default physics scale produces quite slow results. If you're looking to do anything that requires fast movement (e.g. pinball) then reduce the physics scale.
crazy_asian
9
Years of Service
User Offline
Joined: 13th Jul 2015
Location:
Posted: 30th Jul 2015 17:51
Ahh, good to know guys. Thanks for the tip!

Tim
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 30th Jul 2015 18:03
I think the default scale is around 1 metre / pixel.
That makes an average screen about 1 KM wide.
It's easy to see then why it all looks so slow and airy.

Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt
James Tighe
9
Years of Service
User Offline
Joined: 22nd Jul 2015
Location: Portsmouth, Hampshire, UK
Posted: 30th Jul 2015 21:47
Cool cheers for the help guys. Much appreciated. This forum is a very helpful place!

It seems to be working much better now and for reference I do think it was the SetPhysicsScale. On my original project it was set to 1. Lowering it works a treat and the movement is soooo much faster! Thanks Funnell7!

One other question regarding the physics is stopping the jump at a certain height is there a good way to code that the sprite can only jump a certain Y distance from the start point of the jump?

I tried to use a while loop but it kept crashing the player.



I'm basically trying to get the current sprite Y position at the beginning of the jump and run the jump loop until the new y distance is 100 pixel more than the start position.

As stated any condition in the while loop break the player. Has anyone got a good way to limit the maximum height of a physics based jump?

Brian Kuh: If anybody wants to see, there's a Donkey Kong kill screen coming up.
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 30th Jul 2015 23:20
is belongs the virtual resolution
Quote: "
By design the physics system is set to use 1 unit as equalling 1 meter, which in the case of default world coordinates (100,100) would mean that the screen is 100 meters by 100 meters in the physics simulation. However by design the physics system is designed to work best with dynamic objects ranging from 0.1 meters to 10 meters in size, and with static objects up to 50 meters, so the screen is scaled down when sent to the physics system, by default the scale is 0.2, so in the physics world the screen is 20 meters by 20 meters.
"


AGK 108 (B)19 + AppGameKit (Steam) V2 Beta .. : Windows 8.1 Pro 64 Bit : AMD Radeon R7 265 : Mac mini OS X 10.10 (Yosemite)
CJB
Valued Member
20
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Essex, UK
Posted: 31st Jul 2015 12:17
There is a maximum velocity to be considered which can often cause that slow-motion feel when physics scale is too high... This was from Paul in an old thread on the same subject:

Quote: "There is a maximum velocity in Box2D of 2 meters per time step (or 120 meters per second at 60fps). You can adjust the simulation size with SetPhysicsScale so that your screen size is an appropriate number of meters. For example the default scale is 0.2, so a resolution of 1024x768 makes the screen 205x154 meters in size, which is quite significant. "


V2 T1 (Mostly)
Phone Tap!
Uzmadesign
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 31st Jul 2015 19:29 Edited at: 31st Jul 2015 20:48
me make an new jump example ...



AGK 108 (B)19 + AppGameKit (Steam) V2 Beta .. : Windows 8.1 Pro 64 Bit : AMD Radeon R7 265 : Mac mini OS X 10.10 (Yosemite)

Login to post a reply

Server time is: 2024-11-25 19:25:35
Your offset time is: 2024-11-25 19:25:35