GameMaker How to create solid impassable objects(walls)

M

msrifkin

Guest
Just finished the tutorial for GM2, and while it was very helpful it left out one very important thing.

In drag n drop, how do you create an impassable object such as a wall?

Is it in the tile settings? Do i need to create a new sprite/object etc?

Thanks for the help!
 
M

Majindoom

Guest
I started only a few months ago with GMS2 I have never used dnd but you do need collision objects. I make my levels with the tilesets and i have a few non visible collision objects I use for solid impassable and things like water and quicksand objects just slow the character. This is the best practice since haveing your level objects do the collision for you creates more overhead than is needed. With non visible collision objects you will use much less. Hope that helps some. But like i said i can't help with dnd.
 

Geoff Jones

Member
Just on a side note, I'd really suggest learning the GML coding instead of drag n drop. There seems to be a lot more help out there for GML.
 

codemouse

Member
To jump into this thread for a minute - while I totally understand how tilemap collision would be faster perf wise than objects, do you think it's still better to go hybrid or does that lose the advantages?

Ex: Say I'm building a...Zelda game? Something where gravity is not needed but one would expect a variety of fixed collision as well as objects. There is an awful lot of tile collisions (walls, anything unmoveable) but also object collisions (enemies, moveable blocks, etc)

I imagine using a hybrid (testing for both) would reduce the number of total instances in a room by a lot, but just wondering if testing using get_at_pixel is just substantially better than rolling object testing (place_meeting)?
 
P

Pontus

Guest
I started only a few months ago with GMS2 I have never used dnd but you do need collision objects. I make my levels with the tilesets and i have a few non visible collision objects I use for solid impassable and things like water and quicksand objects just slow the character. This is the best practice since haveing your level objects do the collision for you creates more overhead than is needed. With non visible collision objects you will use much less. Hope that helps some. But like i said i can't help with dnd.
Hi! im really new to gm but im trying to figure out how to make a solid wall (in dnd), so i went in here to find out so my question is..... which tile thingy is it?
 

TheouAegis

Member
Ex: Say I'm building a...Zelda game? Something where gravity is not needed but one would expect a variety of fixed collision as well as objects. There is an awful lot of tile collisions (walls, anything unmoveable) but also object collisions (enemies, moveable blocks, etc)
Are your enemies tiles? No. So there's no argument here. Could you make your enemies tiles? Sure, in which case tiles-only would be easily doable, although your enemies would have very few attributes in that case. As for movable blocks, those were handled as tiles until Link pushed on them, then the tilemap was modified and a sliding block object was created, allowed to move into place, and then the block object was destroyed and the tilemap was again modified.

Nowhere in any tile collision tutorial has it ever been stated or suggested that objects should not be used at all. Objects are practically a necessity in Game Maker. The point is you should not be flooding your rooms with thousands of instances of objects whose sole roles are to provide collision detection.

A tile has considerably less overhead than an object.
(estimated list based on GMS1, possibly smaller in GMS2)
Code:
background
layer
left
top
width
height
alpha
angle
xscale
yscale
Even invisible objects take up a lot of overhead:
(variables from GMS1)
Code:
alarm[0]
alarm[1]
alarm[2]
alarm[3]
alarm[4]
alarm[5]
alarm[6]
alarm[7]
alarm[8]
alarm[9]
alarm[10]
alarm[11]
bbox_bottom
bbox_left
bbox_right
bbox_top
depth
direction
friction
gravity
gravity_direction
hspeed
id
image_alpha
image_angle
image_blend
image_index
image_number
image_single
image_speed
image_xscale
image_yscale
mask_index
object_index
path_endaction
path_index
path_orientation
path_position
path_positionprevious
path_scale
path_speed
persistent
phy_active
phy_angular_damping
phy_angular_velocity
phy_bullet
phy_col_normal_x
phy_col_normal_y
phy_collision_points
phy_collision_x
phy_collision_y
phy_com_x
phy_com_y
phy_dynamic
phy_fixed_rotation
phy_inertia
phy_kinematic
phy_linear_damping
phy_linear_velocity_x
phy_linear_velocity_y
phy_mass
phy_position_x
phy_position_xprevious
phy_position_y
phy_position_yprevious
phy_rotation
phy_sleeping
phy_speed
phy_speed_x
phy_speed_y
solid
speed
sprite_height
sprite_index
sprite_width
sprite_xoffset
sprite_yoffset
timeline_index
timeline_loop
timeline_position
timeline_running
timeline_speed
visible
vspeed
x
xprevious
xstart
y
yprevious
ystart
It doesn't matter if you don't enable physics. It doesn't matter if you don't assign a sprite. It doesn't matter if you don't use timelines. It doesn't matter if you don't use alarms. As soon as you put an instance in the room, memory is allocated for ALL of those variables and most of those variables take up 8 bytes each. Now multiply that by 1000.
 
P

ph101

Guest
Are your enemies tiles? No. ... As soon as you put an instance in the room, memory is allocated for ALL of those variables and most of those variables take up 8 bytes each. Now multiply that by 1000.
Good points. Can I ask you a couple of questions?
1. The vid is gm2 - what is the most common way for collision with tiles in gm1.4. Is it generally just mathematical ie you can't go in a grid psace that is occupied?
2. I have a bunch of nps using mp_potential step to move around objects along different paths. But there are many tiles and walls - which need to be objects to prevent collision. Is there any way to reduce object overhead? Maybe I could only spawn the solid walls when they are nearby npc's?
 

TheouAegis

Member
Loop through each tile cell, check its attribute, then block it with mp_grid_add_cell(). You need only one grid, so it can be done at the start of the room or when terrain changes.
 
Last edited:
P

ph101

Guest
Loop through each tile cell, check its attribute, then block it with mp_grid_add_cell(). You need only one grid, so it can be done at the start of the room or when terrain changes.
Thanks for the reply. Yes its probably the best way - sadly for me I'm using a kind of amalgamation because although npc's pathfind in the way you describe, they need to often collide and bounce off each other and thus i use mp_potential_step to step to towards sequential points on the path, meaning I also need solid instances for walls they may encounter allowing them to bump off each other and walls as they go. Also the grid and number of walls can be potentially huge in my game so its very tricky. I'm considering only spawning the wall instances when an npc is in an adjacent grid, but it seems messy and slow too. Alternatively I guess I would need to code my own mp_porential_step which can check solid collisions and a grid and consider it solid in the same way mp_potential_step steps around solid masks, but thats is almost certainly beyond me. Any ideasm although I'm sure there is no silver bullet! (sorry for taking it off topic if this is off topic!)
 

AriesGames

Member
Way off topic but really?
This thread has 15k views, that's a bug right? o_O

Edit: Ohh this is since 2017, so it's not a bug at all...
 
Last edited by a moderator:
M

Mallard8

Guest
Followed the GM Wolf tutorial but it doesn't work when I run my game the object just falls off the screen.
Anybody else have this problem?
 

flyinian

Member
I currently do. Stuck many hours into the code. Trying different things. Checking code. Etc....

Followed the GM Wolf tutorial but it doesn't work when I run my game the object just falls off the screen.
Anybody else have this problem?
 
Top