Two sprites have changed roles

ravatex

Member
So I tried making a wall(obj_WALL) like this video said "GameMaker Studio 2: Complete Platformer Tutorial" and it worked wonders, but when I tried to put a second object the code broke(or I did something dumb) and the collision system only worked with that second object("obj_CHIMNEY") and when I switched from it saying "spr_WALL" to "spr_CHIMNEY" the code worked as intended
Screenshots to help you understand:
1639330110092.png
This is the code for the character named "obj_GRANDMA"
and these are the other objects
1639330193194.png
1639330212948.png



So basically right now when i go on the wall if fall through but when I touch the chimney the collision system works only for the chimney
and if i change the code to mention the spr_CHIMNEY it works for the wall and not for CHIMNEY
Please help a noob out I didnt know what to search so I just came to the forums🦷
 

chamaeleon

Member
You don't use sprites in collision functions. You use instances or objects (in your case, objects). spr_CHIMNEY and spr_WALL are not objects. obj_CHIMNEY and obj_WALL are objects.
 

ravatex

Member
You don't use sprites in collision functions. You use instances or objects (in your case, objects). spr_CHIMNEY and spr_WALL are not objects. obj_CHIMNEY and obj_WALL are objects.
I feel really dumb, but thank you that fixed everything! Now looking back, I cant believe I didnt try it out... Thank you, you made my life a billion times easier!
 
Also, if you want collisions to apply to multiple objects, make the other objects that collisions should apply to a child of obj_WALL (you can find this under the Parent button on the object info). That way, you only need to check for obj_WALL and it will detect all of it's children as well instead of having to write separate collision code for each object.

Oh, and next time, copy and paste your code between [code=gml][/code] tags instead of taking a screenshot. If we want to edit a part of your code, we want to be able to copy and paste it, not type out the whole thing again ourselves =P
 
Top