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 Behavior Question

Author
Message
SageTech
19
Years of Service
User Offline
Joined: 3rd Dec 2004
Location: Orlando, Florida
Posted: 8th Jun 2012 13:54 Edited at: 8th Jun 2012 13:56
I'm trying to create a building structure made out of Metal Beams. Below is the Code which sets this up:



EDIT: I'm running this in a 1024X768 Resolution

I've set the sync rate to 1 to slow it down so that you can see whats happening more clearly. Basically, before I had enabled physics all the beams were lined up perfectly so that they should be be supported and the building should stay erect. However, from what I can tell the problem is as the physics simulation adds more shapes on top it sort of bounces the beams below, additionally the shapes seem to twitch and not stay where they were originally positioned. Is this just the standard functionality of the physics system or is their some property I can adjust to make the beams act more realistically?
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 8th Jun 2012 15:00
It might work better if you don't turn physics on until after everything is in place. That will help in two ways; first your structure is more likely to settle quickly if everything is placed correctly; second you can leave physics off to see if your positioning code is correct.

I would add all items to an array as they are created and then turn physics on by looping through the array.

Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 8th Jun 2012 18:06
I tried baxslash's suggestion and added some frame rate changes this way:


When I left the frame rate at 1, the building built stabily, but once physics was turned on, it crumbled.

When I changed the frame rate, it worked very nicely. Cool physics demo!

Cheers,
Ancient Lady
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 8th Jun 2012 18:09 Edited at: 8th Jun 2012 18:11
You can actually have quite a bit of fun playing with deleting select girders!

But, then again, I am so easily entertained.

EDIT: This looks like a good start for a kid's game.

Cheers,
Ancient Lady
polomint
12
Years of Service
User Offline
Joined: 3rd Apr 2012
Location: Lancashire, United Kingdom
Posted: 8th Jun 2012 20:12
Ooooo, I must have a play,

Blackberry App Development & ZX Spectrum Game Development.
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 8th Jun 2012 21:15
It's fun. But, as I said, I'm easily entertained (just ask anyone in my family).

Cheers,
Ancient Lady
SageTech
19
Years of Service
User Offline
Joined: 3rd Dec 2004
Location: Orlando, Florida
Posted: 10th Jun 2012 10:31
Thanks, it started off as just a tech demo, where I was experimenting with buildings that could be damaged in real time during an action game. But, I found that it was kind of fun to just randomly delete select girders and see how you can effectively implode the tower. I'm working on a game now using this concept, I'll post a wip when I make a little more progress
Impetus73
12
Years of Service
User Offline
Joined: 28th Aug 2011
Location: Volda, Norway
Posted: 10th Jun 2012 12:55
Physics are inherently inaccurate, but here is my best shoot! I don't think the percentage system works too good with physics, so I use virtual resolution system, to get pixel perfection.

The sprites are setup at pixel perfection, but as soon as the physics system is activated, some forces messes with that.




Maybe if one carefully activate physics for each sprite in the right order from the bottom and up, then call Sync() between sets of sprites, it would end up perfectly balanced?

----------------
AGK user - novice
Did Amiga / AMOS programming in the 90's, just started programming again with AGK.

Login to post a reply

Server time is: 2024-04-28 14:59:24
Your offset time is: 2024-04-28 14:59:24