Making more realistic falling?

For questions about using Classic.

Post » Wed Apr 09, 2008 10:19 am

Hi, My gravity I'm using right now is a bit straight and I'm wanting to make it more realistic?
http://www.mediafire.com/?bce2wmtjwmj
B
4
S
2
G
4
Posts: 164
Reputation: 2,178

Post » Wed Apr 09, 2008 11:12 am

Okay, first off... I just took a closer look at your .cap to see what was going on. That movement system is a mess. You're setting your sprites to absolute coordinates on the screen each cycle... that's a really inefficient way to do it.

Instead of an absolute "Set Y to value('height')" you should be doing something like a relative "Set Y to Y + 7" when it's falling.

For some tips on making custom gravity and such, I suggest you check out vinnie's Custom Platform Movement thread here:
http://scirra.com/phpBB2/viewtopic.php?t=613

Anyway, to do acceleration you need to add more to the falling rate every cycle. For instance, on the first tick you'd make the thing move 1px down. Next you'd make it move 2px down. Then four, etc. It all depends on the rate you want. It's best to make a separate variable for acceleration so you can tweak it easily. Those are the basics.

So, in pseudocode:

[code:3ax13xma]
+ Object is not on a platform
- Set value('status') to "falling"

+ Object value('status') Equal to "falling"
+ Object value('fallSpeed') Less than 8
- Add value('gravityAccel') to value('fallSpeed')
- Set Object Y to Y + (value('fallSpeed') * TimeDelta)
[/code:3ax13xma]
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 4 guests