[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
Butterscotch Shenanigans Forums • View topic - GML Help

GML Help

Talk about anything and everything game dev-related here!
Pretty recently ive started using GameMaker Studio, so with medium programming knowledge im just mucking about and making some pretty simple platformers to get used to the syntax and how to do stuff with it, but ive got a problem which i cant think of a way to fix. Here's the code that needs fixing:

//Horizontal collisions
if (place_meeting(x+hspd, y, obj_wall_top or obj_wall_topvine or obj_wall_dirt)) {
while (!place_meeting(x+sign(hspd), y, obj_wall_top or obj_wall_topvine or obj_wall_dirt)) {
x += sign(hspd)
}
hspd = 0
}

x += hspd


It doesnt work cause if two of the objects in the 'or' bit are right next to each other, the place_meeting detects both of them and then obviously doesnt collide normally with the object that its actually going to be 'colliding' with. Any one know how i can fix this?

Ps if anythings a bit unclear, just ask, any replies at all are appreciated.
EDIT: hspd is horizontal speed

Edit E: Also if anyone has another way of coding collisions feel free to reply with that as well! As i say im just learning any new syntax and trying to find the best way of doing things
Last edited by Etrusan on 27 Jun 2015 15:38, edited 2 times in total.
Reason: Use the edit button man.

User avatar
 
Posts: 40
Location: Scotland, UK

Willl respond after popcon weekend! Very limited internet access here, oddly.

User avatar
 
Posts: 1371
Location: St. Louis, Missouri, USA

Cheers! Hope it was good

User avatar
 
Posts: 40
Location: Scotland, UK


User avatar
 
Posts: 1371
Location: St. Louis, Missouri, USA

I'm really glad this worked haha, i cant imagine id have found out anywhere else that i needed to layout my code differently so its much appreciated, and cheers for taking the time to explain it well! All i need to do now is get round the problem of my character getting randomly stuck to the wall objects - which is a pain - ive tried resizing the sprite canvases but that never worked, so im gonna learn how to use collision masks and hopefully that does the trick

User avatar
 
Posts: 40
Location: Scotland, UK

Indeed! And be sure not to use precise collisions.

User avatar
 
Posts: 1371
Location: St. Louis, Missouri, USA

I take it its pointless or not very good?

User avatar
 
Posts: 40
Location: Scotland, UK

Precise collision checking means Game Maker has to check every pixel in the collision mask. The others (diamond, rectangle, circle) allow simple mathematical calculations to be used instead (is this circle overlapping that square).

So Precise Collisions are VERY cpu-intensive. On top of that, they generate weird behaviors, like if your character has his arm sticking out and falls off a ledge, his arm will catch on the ledge and he'll be stuck.

User avatar
 
Posts: 1371
Location: St. Louis, Missouri, USA

Cant really see how theres a lot of situations that that would be useful, especially from a bitmap type perspective as you say. Looks like i can forget about that feature hahah, better to know how to do it yourself anyways

User avatar
 
Posts: 40
Location: Scotland, UK


Return to Game Dev

Who is online

Users browsing this forum: No registered users and 2 guests

cron