GMS 2.3+ Objects not meeting

Elicarus

Member
Hello, I'm still discovering GMS, and I keep having issues, and questions about some behavior. 😅
Here is what brings me this time :
not_meeting.PNG
The script in the left is used by the tree, and the Object1 is that character.
Because I think it's hugely link, I add that i put "depth = -y" in both of the object's code, as a member adviced me to, in order to create an effect of perspective. It could also have a link with the fact that the two objects have their collision mask at the bottom of their sprite (the feet/the roots), and that their sprite's center is at bottom left.
I tried to put an idle object right on the tree's collision mask and the console showed that the tree and the idle object were meeting. After many tries, I managed to make the character and the tree meet but only in single-pixeled area in the top left of the tree's collision mask.
I really don't see what i could do.
Any help would be very appreciated! Thanks! :)
 
Last edited:

Rexzqy

Member
I am sorry but could you explain again about what do you want to achieve? A bigger collision mask or?

From what I read you want to check an area around the tree, in that case you can use collision_circle(), use the tree's coordinates and check for player or other object u want to check for
 

Elicarus

Member
I am sorry but could you explain again about what do you want to achieve? A bigger collision mask or?

From what I read you want to check an area around the tree, in that case you can use collision_circle(), use the tree's coordinates and check for player or other object u want to check for
Sorry for the confusion.
Actually, what I want is to show a textbox when you're "against" tree and press enter.
Everything is working very well, except that "against" part. What I mean by that word is that the character is blocked on a side by the tree. The goal is that the player has too go very close if he wants a dialog to show up, so if you press enter and are nearby the tree but not touching it, it shouldn't work.
 

Rexzqy

Member
Sorry for the confusion.
Actually, what I want is to show a textbox when you're "against" tree and press enter.
Everything is working very well, except that "against" part. What I mean by that word is that the character is blocked on a side by the tree. The goal is that the player has too go very close if he wants a dialog to show up, so if you press enter and are nearby the tree but not touching it, it shouldn't work.
try this:

collision_circle( x(the x of the tree), y(y of the tree), rad(however big you want the checking circle to be), Obj1(the player object), false, true);

and to check exactly how big this collision circle is, use draw_circle in the draw event of the tree, and put draw_circle(x,y,rad(the rad you put in collision_circle),true)

This function is better for checking if the player is near an circular area adjacent to the tree object. place_meeting only works when the two objects are colliding and that's probably too strict for what you want to achieve.

*actually nvm, i read and it appears u want the player to be very close to the tree. you could still use a small rad value for that.

If anything's unclear just ask!! English is not my native language so I know my english could be confusing😂
 
Last edited:

Elicarus

Member
Thank you for your help! But is there a function i could use to get the position of the collision mask as we can see it when we modify it? In the collision mask part of the Sprite window there are the "top, left, right, bottom" coordinates of the mask. Any way I can get them in order to use them the script?
 
Last edited:

Nidoking

Member
Thank you for your help! But is there a function i could use to get the position of the collision mask as we can see it when we modify it? In the collision mask part of the Sprite window there are the "top, left, right, bottom" coordinates of the mask. Any way I can get them in order to use them the script?
Why would you need that? Are you asking a new question? You just have to adjust the x or y value in the call to place_meeting by one. That will tell you whether the two instances meet if you shift one over by one pixel.
 

Elicarus

Member
Why would you need that? Are you asking a new question? You just have to adjust the x or y value in the call to place_meeting by one. That will tell you whether the two instances meet if you shift one over by one pixel.
Well, i need it to have a good center for my collision circle
 
Top