# 3D multiple floors

7 replies to this topic

### #1 lethman427

lethman427

GMC Member

• New Member
• 58 posts

Posted 17 November 2011 - 11:43 PM

Hello GMC! I am having troubles creating 3D floors(3D Gravity). My idea is to somehow check the player z values against the floor's z values and adjust the zspeed accordingly. I can do this with single levels (no floor objects over-lap), but i would like to do at least 2 or more floors over top of each other.
Ex:

_____________ - Top floor
0
_
| - Me
^
_____________ - Second Floor

_____________ - Ground Floor

Does anyone have any ideas? (code would be greatly appreciated )
• 0

### #2 brett14

brett14

GMC Member

• GMC Member
• 1150 posts
• Version:GM8

Posted 18 November 2011 - 02:11 AM

• 0

### #3 AndrewBGM

AndrewBGM

GMC Member

• GMC Member
• 199 posts
• Version:GM:Studio

Posted 18 November 2011 - 01:48 PM

There's no need to use a DLL, this is all very possible with GML alone.

First, here is the process you need.
• Fill an array with objects we are colliding with at x:y
• Loop through the array and find the one with the highest z value, but with the z below our current z
• Make our landing point this objects z value

I don't have access to GM at the moment but this is how I have done it in the past.
• 0

### #4 lethman427

lethman427

GMC Member

• New Member
• 58 posts

Posted 19 November 2011 - 02:19 AM

... Andrew's method seem's to work. I need to add real stairs, but it looks good so far. Any tips on how to handle the stairs?
• 0

### #5 jheard901

jheard901

GMC Member

• New Member
• 33 posts

Posted 21 November 2011 - 09:37 PM

I'm working on a 3D game and I happen to be struggling with the exact same problem: how to make different level floors in one instance of a room. I still don't really get what Andrew said (still have a basic understanding of GML programming), but I happen to have found a tut that can help out with making 3D stairs. This was not done by me, but one of the other members of GMC.

http://www.host-a.ne...airs13_Done.gm6
• 0

### #6 AndrewBGM

AndrewBGM

GMC Member

• GMC Member
• 199 posts
• Version:GM:Studio

Posted 22 November 2011 - 11:48 AM

... Andrew's method seem's to work. I need to add real stairs, but it looks good so far. Any tips on how to handle the stairs?

Stairs could be a little tricky. You could just apply the same method for checking solid positions, but if there is a stair object, alter the z position.

Edited by AndrewBGM, 22 November 2011 - 11:49 AM.

• 0

### #7 jheard901

jheard901

GMC Member

• New Member
• 33 posts

Posted 24 November 2011 - 01:32 AM

... Andrew's method seem's to work. I need to add real stairs, but it looks good so far. Any tips on how to handle the stairs?

Stairs could be a little tricky. You could just apply the same method for checking solid positions, but if there is a stair object, alter the z position.

I don't remember where I got it from
• 0

### #8 Popcorn123

Popcorn123

JNC Games Creator

• GMC Member
• 371 posts
• Version:GM8

Posted 26 November 2011 - 04:06 PM

for the stairs issue i did this in my fps game:
object stairs draw:
//draw stairs
z=0
{
d3d_draw_block(x,y-32,z, x-64,y+32,z+12, background_get_texture(background1),1,1)
d3d_draw_block(x,y-32,z+12, x-48,y+32,z+24, background_get_texture(background1),1,1)
d3d_draw_block(x,y-32,z+24, x-32,y+32,z+36, background_get_texture(background1),1,1)
d3d_draw_block(x,y-32,z+36, x-16,y+32,z+48, background_get_texture(background1),1,1)
}
the stairs sprite's origen must be at the left middle side of a 64x64 sprite.
Then for the player object:
Create:
//set z motion stuff
zdirection=0;
zspeed=0;
zgravity=0;
Step:
{//check for ramps
if collision_circle(x,y,2,stair,false,false) then
{
zgravity=0;zspeed=0;
near=instance_nearest(x,y,stair);
z=48-distance_to_point(near.x,near.y);
}
else
script_execute(scr_BlockCheck);
scr_BlockCheck:
z=0
//check for bumping against blocks
if collision_circle(x,y,2,wall_par,false,false) then
{
near=instance_nearest(x,y,wall_par);
if near.z>= z then script_execute(scr_CameraBump);
}
else
{zgravity=1;}
scr_CameraBump:
//camera bumps into solid things
x=xprevious;
y=yprevious;
speed=0;
This is what i used any way.

Edited by Popcorn123, 26 November 2011 - 04:09 PM.

• 0

#### 0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users