(SOLVED)How do you get the id of an instance your colliding with?

D

Den

Guest
I'm trying to make each collision with my door objects instances unique when the player collides with it so
I can turn off the object being solid and pass through it, coz i'm using a collision_line check for my
enemy's line of sight check and my door object is a child of my obj_solid (which handles all my solids)
Iv tried instance_find but that just keeps giving me the same instance number for any door the player collides with.
Is there some way you can just get the specific id of the current door instance i'm colliding with?
 

FrostyCat

Member
If you are using standard collision events, the colliding instance's ID is other.id.

If you are using collision checks in the Step event, use instance_place() instead of place_meeting().
Code:
var colliding_door_id = instance_place(x, y, obj_door);
if (colliding_door_id != noone) {
  //...
}
PS: Did you follow any tutorials or guides for this? If it was the slightest bit competent, this should have been covered.
 

Neptune

Member
instance_position checks a single point for an object-instance -- returns ID if found.

instance_place checks an area as large as the calling instance's sprite at the desired point for an object-instance -- returns ID if found.

position_meeting checks a single point for an object instance -- returns 'true' if found.

place_meeting checks an area as large as the calling instance's sprite at the desired point for an object-instance -- returns 'true' if found.

So there are only the two kinds of checks (single point or area). It just depends if you need an actual ID return, or a simple boolean return.
 
D

Den

Guest
nstance_position checks a single point for an object-instance -- returns ID if found.
So really I should just change my collision code from place_meeting to instance_place then.
 

Neptune

Member
Yeah, i think instance_place is a bit taxing to call constantly. Maybe like:
Code:
if place_meeting(x,y,o_door)
{
var door_inst = instance_place(x,y,o_door);
}
Or something similiar?
 
Top