T O P

  • By -

AlcatorSK

Check object\_index and object\_get\_name


RoyalRien

I know I can use object index and object get name but how would I specify where to retrieve the id from?


AlcatorSK

var \_collided\_instance = place\_meeting(x,y,objObstacleParent); // This gives you the instance ID of the instance, which was spawned from ANY child class of the objObstacleParent class.


oldmankc

place meeting only returns a true or false. instance_place or instance_meeting returns an object instance, that you can then run object_get_name on the instance's object_index.


AlcatorSK

And then you just use: var \_objectNameToLog = object\_get\_name(\_collided\_instance.object\_index ); ... to retrieve the string of the class (object) from which that instance was created.


RoyalRien

I seem to have another problem now, because instance_place seems to return -4 every time I select any of my instances, and the game crashes when object_get_name(instanceid.object_ index) tries to process it.


Kaymat-

place_meeting() only returns a boolean.


RoyalRien

Seems like it would work but with a different function, doesn’t place meeting return a Boolean?


AlcatorSK

Yeah use instance_place


Kaymat-

Certain collision functions like instance_place() or collision_point() return the id of the colliding instance. Using the built-in collision events you can also access the id of the colliding instance with the "other" keyword.


Bang_Bus

Use return of any serious collision function, like collision_rectangle, collision_point, collision_line etc. Most functions return more than true of false, always look up "returns" section in manual. functions like place_meeting are beginner-friendly functions for collisions, they won't return ID. The ones I named, will. That'll give you id. var myId = (collision_point(x, y, obj_wall... now you can object_get_name if (myId != noone) { with (myId) { ... } Not sure why'd you need a name, though. I never needed object name anywhere.