• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

GameMaker colision_circle and place_meeting not working

duran can

Member
I try to make a platform game using physics, but when I press W constantly, the acter flies without touching the ground. Is this a bug?

GML:
if keyboard_check(ord("W")){
    if place_meeting(phy_position_x,bbox_bottom+1,obj_mask){
    physics_apply_impulse(x,y,0,-zipla);
    }
}
 

duran can

Member
Adsız.png
If i rotate the object in room, this red rectangle triggers collision_ and place_ events. How can I fix this?

 

Jezla

Member
If you are holding the key (as you are checking), then you are applying the impulse every step, so the behavior is working as you have coded it (though you correct that the place_meeting check is unnecessary and won't work, so leave them out).

If you are trying to make the character jump, then you need to use keyboard_check_pressed() on your input to determine whether or not to apply the impulse.
 

duran can

Member
If you are holding the key (as you are checking), then you are applying the impulse every step, so the behavior is working as you have coded it (though you correct that the place_meeting check is unnecessary and won't work, so leave them out).

If you are trying to make the character jump, then you need to use keyboard_check_pressed() on your input to determine whether or not to apply the impulse.
First of all thank you for your answer. I don't think my problem here is with keyboard_check_pressed () or keyboard_check (). I could also sync the character to mouse coordinates.

Or imagine a Bullet object with a very simple example. If this object constantly checks with place_meeting () it will disappear without touching this wall.

This only applies to objects whose angle is changed in the room. On other objects, place_meeting () works normally. But I want to use changing the angle of the objects for the room design. Making myself a room editor is a laborious task.


any helps from admins @Nocturne ?

im using steam bundle version btw if important.
 

Alexx

Member
I think you would be better off coding your own movement system, physics isn't really that suitable for a platformer.
 

Nocturne

Friendly Tyrant
Forum Staff
Admin
You can't mix and match the physics system with the traditional system. Things like place_meeting depend on bounding box and x/y position, but physics objects use phy_position_x/y and collisions should be checked using the collision event and the specific physics collision function physics_test_overlap(). Basically, when using the physics functions, ONLY use the physics functions and forget about all the others.

Apart from that you also have to delicately balance the gravity vector, the pixels-to-meters ratio and the impulses/forces used to get the "jump" right and to avoid the "floaty" feel. Also, ensure that the jump mechanic only works once (ie: check if the instance is in the air and only permit the jump key to work if it's not).

I would also iterate that the physics system is NOT a good fit for a platformer game, as others have already mentioned... not saying it can't be done, but it'll over-complicate things and unless you 100% need physics in your game, then I wouldn't use it. I see a lot of users going with physics because "it makes collisions easier", but it makes everything else harder!

PS: Please don't summon myself or any other member to a topic unless they have already replied or explicitly said that you can ping them to help. ;)
 

duran can

Member
I'm talking about a mistake here, you call me don't use it. Maybe I just bought gamemaker studio for this feature? Is it right to approach the customer in this way? I have used Unity or similar game engines, and I have never seen what they say "We made rigidbody system but don't use".

"it makes collisions easier" yes we use it for this because I think this is the purpose of the game making engine, not making it difficult.

I do not understand why you are trying to have a discussion instead of focusing on the problem.

Also, as I showed here in video 2, there is no problem with the physics system, I wish you had watched the video. If I rotate an object in the room, commands such as place_meeting or position_meeting do not work on that object. (Whether physics or not.)

Anyway, if someone really wants to help, there is a problem like below ...

Example without physics:
obj_1 object draw event
GML:
draw_self();

draw_text(15,15,string(bbox_bottom));

if position_meeting(x,bbox_bottom,obj_block){

draw_text(15,35,"collision triggered");

draw_circle_color(x,bbox_bottom,5,c_green,c_green,0);

}else{

draw_circle_color(x,bbox_bottom,5,c_red,c_red,0);

}

x=mouse_x;y=mouse_y;
and create some obj_block and rotate in room

Adsız.png
 

Nocturne

Friendly Tyrant
Forum Staff
Admin
Did you care to read what I said?
You can't mix and match the physics system with the traditional system. Things like place_meeting depend on bounding box and x/y position, but physics objects use phy_position_x/y and collisions should be checked using the collision event and the specific physics collision function physics_test_overlap(). Basically, when using the physics functions, ONLY use the physics functions and forget about all the others.
Physics objects use FIXTURES for collisions, and those do not correspond to the mask, sprite or bounding box for the sprite. They are two completely different systems and you are mixing them. You can't. And if you are not using physics and have the issue, it is because (as someone has already pointed out) you need to create a precise collision mask for the instance, otherwise you are going to get BBox collisions (although if the platform you are using is a rectangle, you can use the rotated-rectangle mask). This is an issue with you not understanding the systems you are using and you should really check the manual section that explains how collisions work (see the "Collision Mask" section on the Sprite Editor, which has images showing how they work: https://docs2.yoyogames.com/index.html?page=source/_build/2_interface/1_editors/sprites.html ).

And I'm not saying "don't use physics", I'm saying "don't use it in this way". I love the physics in GMS and have used it for all sorts of projects... but it's a question of using it appropriately. In my opinion (which you requested) using physics to make a platform game is not appropriate. Physics are meant to be used to simulate REAL WORLD PHYSICAL INTERACTIONS, and there is nothing about a platformer that is like the real world.

Also, don't criticise me for giving you my advice when you summoned me into this topic.
 
Top