The physics system is already doing the perfect collision, codes like place_meeting and collision_circle don't work.Precise collision?
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.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.
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.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;
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 ).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 usephy_position_x/y
and collisions should be checked using the collision event and the specific physics collision functionphysics_test_overlap()
. Basically, when using the physics functions, ONLY use the physics functions and forget about all the others.