# Any resources/info on top-down platforming??

M

#### mccordinator

##### Guest
I'm working on a top down game. I want to have multiple height platforms, etc in each area. I feel like I'm decently close to an answer, but I'm wondering if anyone has ever implemented this or seen a tutorial about doing so. I've been at this for a month or so.

My current approach is using a z axis and trying to assign a height variable to platforms above ground level. I'm wondering if everything could just work off of z without another variable like height, etc.

Any advice or guidance is majorly appreciated!!

Last edited by a moderator:
M

#### mccordinator

##### Guest
I ran through and completed this Udemy tutorial by Heartbeast https://www.udemy.com/make-an-action-rpg-in-gamemaker-studio-2/ and now I would like to add in some platforming with platforms and such at multiple heights like Alundra on PS1

As far as I can tell I need to add in some more physics, but I'm wondering how far in to the 3d realm I need to go.

I don't need a rotating camera, just consistent physics and I guess tracking of the players z_ value at all times. I've been attempting this for about a month and I'm really not sure I am going about it the right way.

I have the usual movement code with place_meeting, and I've tried throwing in a z on the collision checking.

Code:
``````    var _x_speed = lengthdir_x(speed_, direction_);
var _y_speed = lengthdir_y(speed_, direction_);

if place_meeting(x+_x_speed, y + z_, collision_object_) {
while !place_meeting(x + sign(_x_speed), y + z_, collision_object_) {
x += sign(_x_speed);
}

_x_speed = 0;
}
x += _x_speed;

if place_meeting(x, y+_y_speed + z_, collision_object_) {
while !place_meeting(x, y+sign(_y_speed) + z_, collision_object_) {
y += sign(_y_speed);
}

_y_speed = 0;
}
y += _y_speed;``````

Right now if the player is colliding with a "platform" object, then I call a different collision handling method:

Code:
``````   /// @param jumpable

var _jumpable = argument0;

var _x_speed = lengthdir_x(speed_, direction_);
var _y_speed = lengthdir_y(speed_, direction_);

if place_meeting(x+_x_speed, y + z_, _jumpable) and (state_ != player.jump)
{
while !place_meeting(x + sign(_x_speed), y + z_, _jumpable) {
x += sign(_x_speed);
}

_x_speed = 0;
}

if (z_ <= _jumpable.height_)
{
x += _x_speed;
_player_jumped = true;
}

if place_meeting(x, y+_y_speed + z_, _jumpable) and (state_ != player.jump) {
while !place_meeting(x, y+sign(_y_speed) + z_, _jumpable) {
y += sign(_y_speed);
}

_y_speed = 0;
}

if (z_ <= _jumpable.height_)
{
y += _y_speed;
_player_jumped = true;
}

// Make sure to update speed and direction
speed_ = point_distance(0, 0, _x_speed, _y_speed);
direction_ = point_direction(0, 0, _x_speed, _y_speed);

//here I am trying to end the jump if you land on a platform
if ((floor(z_) <= _jumpable.height_) and (_player_jumped))
{
z_ = _jumpable.height_;
z_speed_ = z_speed_max_;
gravity_ = gravity_max_;
state_ = player.move;
}``````
All of this has gotten me to a kind of weird spot that you can see in this gif here http://gph.is/2FgbSYz.

Seems like it works ok at first, and I land on the platform, but after that I can't jump and height stays the same when I walk off because I don't have any gravity pull yet I guess.

This is what my jump state looks like:

Code:
``````    /// @description Jump State

z_ += z_speed_;
z_speed_ += gravity_;

if (x_input_ == 0 and y_input_ == 0) {
// Not Moving
image_index = 0;
image_speed = 0;
apply_friction_to_movement_entity();
} else {
image_speed = animation_speed_;
image_xscale = x_input_ == -1 ? -1 : 1;
get_direction_facing(input_direction_);
roll_direction_ = direction_facing_ * 90;

move_movement_entity(false);
}

if (z_ >= starting_z_ and z_speed_ > -1) {
z_ = starting_z_;
z_speed_ = z_speed_max_;
gravity_ = gravity_max_;

state_ = player.move;
}``````
Does anyone have any experience implementing something like this? I feel like I'm getting close, but something is just off. Probably my math?

Player variables set from Create Event:

Code:
``````    z_ = 0;
z_speed_max_ = -4;
z_speed_ = z_speed_max_;
gravity_max_ = 0.25;
gravity_ = gravity_max_;``````

#### Chaser

##### Member
Woh,I’m going to make a top down orthometric/graphic game soon. Didn’t realise it would be so dense, I was just going to create/destroy layers to give the illusion you were walking on higher lower levels. May have to rethink that now then if my way isn’t doable, won’t know till I try, good luck with yours.

#### Genetix

##### Member
First issue is that example is a 3/4 perspective game and not actually top-down. Are you trying to make something like the example a straight top-down (birds eye) game?

M

M

#### mccordinator

##### Guest
UPDATE: Because of an awesome user on reddit, who posted in my thread there, I was able to get to a pretty decent point with this.

I've been working hard on this, and I have actually made some progress as you can see here: https://giphy.com/gifs/3ohc18Ehj1t0NnoaZ2

It still needs a lot of polish, as there are still some slightly buggy things going on. I was more just trying to get the actual z tracking and collision working, but I also managed to work with depth.

I did depth by creating a depth_offset_ which I calculate based on the platform being collided with. Not sure this is the best way though. I think I'm setting depth too high on the player this way.

What changed the game was realizing that I needed some custom rendering for any objects with a z axis. I need their x and y to stay as if they are on the ground, and just draw them with the z offsets.

This allows for collision checking on the x and y axis as normal, and then adding in a little extra checking on z axis.

I set up the engine to draw a red shadow of my player on just the x, y (not factoring in the z like the real player sprite does), and to draw a blue box shadow for my platforms on just the x and y (not factoring in z like the real platform sprites are) to demonstrate this as you can see here the collision checking still happens on x, y and then I can just check z to know if i also have the height to move on to a platform.

This can be seen here with the player/platforms "shadows" along x, y only: http://www.giphy.com/gifs/3ohc0TZdWFUzmnri4E

Shout out to reddit user viniciuscsg who left very helpful comments on my post at https://www.reddit.com/r/gamemaker/...le_based_top_down_platformer_a_la_alundra_on/

#### Yal

##### 🐧 *penguin noises*
GMC Elder
The mistake most people do when they make top-down games with some Z-axis movement is that they don't actually have 3D collision checking code in place, they just simulate parts of it. That generally just makes things complicated in the end. Make a 3D world, then just render it in 2 dimensions.

Example, if you have a z coordinate alongside the build-in x and y, draw an object taking z into account by something like this:
draw_ellipse(x - sprite_width*0.5,y - 8,x + sprite_width*0.5,y + 8,false);
draw_sprite(sprite_index,image_index,x,y - z);
(i.e. don't actually move it up when it jumps, just draw it higher on the screen)

T

#### Thunder Lion

##### Guest
I'm working on a top down game. I want to have multiple height platforms, etc in each area. I feel like I'm decently close to an answer, but I'm wondering if anyone has ever implemented this or seen a tutorial about doing so. I've been at this for a month or so.

My current approach is using a z axis and trying to assign a height variable to platforms above ground level. I'm wondering if everything could just work off of z without another variable like height, etc.

Any advice or guidance is majorly appreciated!!
I feel you may need a height variable for the objects this would start from their standing Z but would indicate say a stray bullet going skyward can hit them when they are above the normal ground or if you want them to duck under things at different heights