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 / Jump through platforms?

Author
Message
Yodaman Jer
User Banned
Posted: 23rd Jul 2015 18:26
Hey gang, I'm thinking about attempting a platformer for a small test and I am wondering how you might make jump through platforms.

For example, in several games, the player can jump up through a platform or ground object, and then land on top of it. Sometimes enemies can be on this object as well. How might one go about this? Every idea I've tried in other engines has never worked out, it seems to be a surprisingly difficult subject. Any pointers would be appreciated!


Official Forum President from June 20th, 2015 - June 20th, 2016 (when my successor is elected, whomever that may be!).
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 23rd Jul 2015 19:50 Edited at: 23rd Jul 2015 19:52
I would create an invisible physics object above the platform - a thin layer. Set this object as a sensor - SetSpritePhysicsIsSensor()

When the player hits the sensor, check the position of the player. i.e is the player above the sensor? If yes, then add the platform to a category (SetSpriteCollideBit()) that the player category collides with.

When the player and platform are no longer touching, reset the platform category bit.

The enemies will already be in categories that collide with the platform.

Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt
lilpissywilly
AGK Developer
13
Years of Service
User Offline
Joined: 10th Sep 2010
Location: Office Chair
Posted: 23rd Jul 2015 21:04 Edited at: 23rd Jul 2015 21:07
Quote: "I would create an invisible physics object above the platform - a thin layer. Set this object as a sensor - SetSpritePhysicsIsSensor()

When the player hits the sensor, check the position of the player. i.e is the player above the sensor? If yes, then add the platform to a category (SetSpriteCollideBit()) that the player category collides with.

When the player and platform are no longer touching, reset the platform category bit.

The enemies will already be in categories that collide with the platform"


If that was a facebook post I would press Like. Excellent!

My hovercraft is full of eels
DavidAGK
AGK Developer
10
Years of Service
User Offline
Joined: 1st Jan 2014
Location:
Posted: 23rd Jul 2015 23:03
You need to decide if you are coding the controller or using physics first...

Using Tier 1 AppGameKit V2
Started coding with AMOS (Thanks Francois Lionet)
Yodaman Jer
User Banned
Posted: 24th Jul 2015 08:07
I would probably use physics, just for simplicity's sake (and to utilize BatVink's easy idea!). But would that be the BEST way? I know there are inherent issues when using physics so I'd like to explore all options.


Official Forum President from June 20th, 2015 - June 20th, 2016 (when my successor is elected, whomever that may be!).
CJB
Valued Member
20
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Essex, UK
Posted: 24th Jul 2015 12:17
What about something like this:

pseudo:
If player move-direction is up
don't check for collision with platforms
else
check for collision with platforms
endif

V2 T1 (Mostly)
Phone Tap!
Uzmadesign
Yodaman Jer
User Banned
Posted: 24th Jul 2015 20:00
Quote: "If player move-direction is up
don't check for collision with platforms
else
check for collision with platforms
endif"


A very good idea! I tried that many times in GameMaker all to no avail, but GameMaker also had its own built-in physics which were impossible to circumvent, so this would probably work in AppGameKit when coded from scratch!

@David:

I've seen your WIP on your platformer, it's quite impressive! How did you achieve the jump through platforms?


Official Forum President from June 20th, 2015 - June 20th, 2016 (when my successor is elected, whomever that may be!).
DavidAGK
AGK Developer
10
Years of Service
User Offline
Joined: 1st Jan 2014
Location:
Posted: 24th Jul 2015 20:32
Regarding physics versus coding the controller - my preference is coded controllers because you have more control over the feel. No doubt about it though, it takes time to get it right, especially with forces and slopes etc

Re jump through platforms, it's a while since I did that code but I recall that the logic ran something like...

1. Record highest point of players's jump
2. Is player falling? (needs to be yes)
3. If player is going to land, is the point where they are landing lower than the highest point of the player's jump? (needs to be yes)

The key for me was to ensure that the player would not 'land' on a platform unless they cleared the platform (ie didn't jump half way up the tile and then somehow magically land on it even though it wasn't cleared.)

It's not too difficult until you add in slopes...then it becomes trickier!

Using Tier 1 AppGameKit V2
Started coding with AMOS (Thanks Francois Lionet)
Yodaman Jer
User Banned
Posted: 24th Jul 2015 20:50
Quote: "1. Record highest point of players's jump
2. Is player falling? (needs to be yes)
3. If player is going to land, is the point where they are landing lower than the highest point of the player's jump? (needs to be yes)"


That's a good system! Definitely prevents those "getting stuck". I will have to keep this method in mind, thank you!


Official Forum President from June 20th, 2015 - June 20th, 2016 (when my successor is elected, whomever that may be!).

Login to post a reply

Server time is: 2024-04-26 10:30:48
Your offset time is: 2024-04-26 10:30:48