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 / Physics! Arggggh!

Author
Message
Grook
AGK Backer
12
Years of Service
User Offline
Joined: 22nd Jun 2012
Location: Lancashire, England
Posted: 6th Jul 2012 19:37
Hi all,

Ok, maybe I'm dim (don't answer that) but I'm really struggling with the physics related commands with regard to the correct values to use for the various functions like SetPhysicsGravity, Set SpritePhysicsImpulse etc. etc. etc.

I just can't seem to get realistic movement, either my gravity is to high or low so things stick to the floor or float, or the impulse I have to give something has a lot of 0's in the number! I can't get my head round the basis that all these functions rely on. Are they affect by the world/screen size I'm working on?

A simple explanation would be wonderful for an old man like me or, better, some guide values I could use to setup a world...

Right, the nurse is calling me - must dash..

"Happiness is contrary to the human condition" --White (to Black)
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 7th Jul 2012 09:12 Edited at: 7th Jul 2012 09:12
Hi grook, a lancashire lad eh? I'm one too

I was born in Orrell and grew up in Ormskirk for my sins.

Take a look at the AppGameKit Bitesize tutorials linked in my signature, they give a few examples of using Physics in a few different ways. I'll be adding a few more soon too.

I hope they help!


this.mess = abs(sin(times#))
Grook
AGK Backer
12
Years of Service
User Offline
Joined: 22nd Jun 2012
Location: Lancashire, England
Posted: 7th Jul 2012 11:25
Aye Lancashire born and bred - though my birthplace is in Merseyside now! Ormskirk's a nice enough place - I spent my childhood years just up the road in Southport.

Thanks for the pointers, I'll take a look through them and see if everything finally clicks into place...

"Happiness is contrary to the human condition" --White (to Black)
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 7th Jul 2012 17:14
Grook, a sample of the code you are trying might help.

I might guess that you are using the set impulse command every Sync cycle. If so, that doesn't work. It needs to be set sporadically (in response to something) and then allowed to do its thing for a bit.

Repeated calls to the command basically reset it, sort of.

Cheers,
Ancient Lady
AGK Community Tester
Digital Awakening
AGK Developer
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Sweden
Posted: 8th Jul 2012 11:29
Quote: "Take a look at the AppGameKit Bitesize tutorials linked in my signature, they give a few examples of using Physics in a few different ways. I'll be adding a few more soon too."


I like your 3rd tutorial. Was trying to use force instead of velocity to control my character. 2 things I would like to see in the next tutorial are 2 "bug fixes":

1. Boxman can jump in mid air. I would like to see an example of how to detect if a character is standing on the ground or a platform.

2. If Boxman is forced against a wall or platform he won't fall down. How to fix that?

baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 8th Jul 2012 11:56
Both of those examples can be fixed using rycasting. Tutorial 5 or 6 is an intro to raycasting. I'll get it finished very soon.

Basically you send a ray out below and either side of the character and check for collisions.


this.mess = abs(sin(times#))
Digital Awakening
AGK Developer
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Sweden
Posted: 8th Jul 2012 12:18 Edited at: 8th Jul 2012 12:26
Thanks for the tip baxslash. Now that you say it, it makes perfect sense. But I only read up on physics, collisions and raycasting yesterday. Thanks to Hands on AppGameKit BASIC I got into it pretty fast. But it doesn't have a game example.


However, in your example with thin platforms. Sending out a ray to the side from Boxman is not very likely to hit a platform. Nor would standing on the edge of a platform register a hit. I would probably use dummy sprites instead of rays.

Login to post a reply

Server time is: 2024-11-23 18:17:31
Your offset time is: 2024-11-23 18:17:31