View Issue Details
|ID||Project||Category||View Status||Date Submitted||Last Update|
|0025162||Runner Suggestions||Functions||Public||2017-01-10 15:51||2018-05-09 10:36|
|Summary||0025162: Suggestion: Functions: [Return ids for all colliders from collision functions, not just the first one found]|
|Description||The collision functions that return an id(instance_place(x, y, object), instance_position(x, y, object), collision_point(x, y, object, precise, notme)...) only return one single id when they find a collision with more than one instance, so if you want to address the rest of the colliding instances you have to write scripts that check repetitively with varying conditions, impacting performance considerably.|
My request is that these functions should return an array or a data structure containing the ids of all instances which are found to be colliding with the calling instance, so there´ll be no need to call them more than once for every check.
|Additional Information||Original helpdesk ticket: http://help.yoyogames.com/tickets/116032|
|Tags||No tags attached.|
||This one is open for discussion on how we would implement it, open to ideas.|
The return values for these are already well-defined and deeply entrenched in popular use, so there is no place for overriding them. A better idea is to implement them as new, separate functions:
Really would like to have the functionality raised above as well.
How about an optional true/false flag in the end of these functions where true means all in area? If using true the result will give a number that works like an object and reference to an Array of instances. Then you just use functions like instance_number(reference) and instance_find(reference,index)... exactly as you do with an object.
I have already filed this and given my suggestions for how it should be handled here: http://bugs.yoyogames.com/view.php?id=24983
I suppose instance_place_list and instance_position_list should also be added to those too...
I would like to suggest that the following functions be added:
They would work exactly the same as the regular collision functions, but have an extra final argument where the user supplies a DS list that would be populated by the instances detected in the collision.
For the collision_point list, the list would be ordered by depth, for collision line, the list would be ordered by distance from point x1/y1 to point x2/y2, for collision_circle the list would be ordered by distance from the center and for collision_rectangle/ellipse the list needn't be ordered (mainly because I can't think of any actual way to order it that would make sense :P ).
Note that the other collision functions could also be given list counterparts, but in general I've only seen these functions get requests for this type of return list, since they are most commonly used for things like lasers and explosions, where a list of instances is useful and required.
|I would prefer to see this feature implemented to return arrays instead of lists. This way we can leave the cleanup to the garbage collector.|