Perihelion
Sponsor
I'm sure I'll have plenty of questions about GML as I attempt to learn it, so I'll be posting them in this thread. Help is appreciated.
I'm trying to figure out how to use the collision functions. Just as a test, I put this in a (perhaps someday) pushable object's collision event with player1:
But it always returns -4. According to the documentation, a negative number means there's no collision. What am I doing wrong? The message box wouldn't pop up if they weren't colliding! Is it only testing the origin of the player1 object or something? Is there a way to check the collision masks instead? There doesn't appear to be a function for that in the collisions documentation, but it would be really useful to be able to do that in code... Do I just have to use the event?
I'm trying to figure out how to use the collision functions. Just as a test, I put this in a (perhaps someday) pushable object's collision event with player1:
show_message(string(collision_point(player1.x,player1.y,par_pushable,true,false)))
But it always returns -4. According to the documentation, a negative number means there's no collision. What am I doing wrong? The message box wouldn't pop up if they weren't colliding! Is it only testing the origin of the player1 object or something? Is there a way to check the collision masks instead? There doesn't appear to be a function for that in the collisions documentation, but it would be really useful to be able to do that in code... Do I just have to use the event?
Relevant Documentation":1f4ubj11 said:When planning motions or deciding on certain actions, it is often important to see whether there are collisions with other objects at certain places. The following routines can be used for this. All these have three arguments in common: The argument obj can be an object, the keyword all, or the id of an instance. The argument prec indicates whether the check should be precise or only based on the bounding box of the instance. Precise checking is only done when the sprite for the instance has the precise collision checking set. The argument notme can be set to true to indicate that the calling instance should not be checked. All these functions return either the id of one of the instances that collide, or they return a negative value when there is no collision.
collision_point(x,y,obj,prec,notme) This function tests whether at point (x,y) there is a collision with entities of object obj.