Raycast should be able to:
- return any (arbitrary) object along the ray
- return all objects
- return closest object
We have only the last option now. This is not enough.
Raycast should be able to:
Is this not possible now? Multiple raycast collisions work in Box2D: https://www.iforce2d.net/b2dtut/raycasting
Maybe the Defold implementation is different.
Related: Raycast with several results
@totebo I think what @dmitriy wants is to use a custom collision filter object, to make it possible to discard or collect any results along the ray cast.
A useful feature, let’s put it on the backlog.
I want something like this:
physics.raycast(from, to, groups, raycast_type)
local hit = physics.raycast(from, to, groups, physics.ANY _HIT)
Returns the first collisionobject discovered that intersects the ray. This may be any(arbitrary) object along the ray. If no object intersects the ray, returns nil.
local hits = physics.raycast(from, to, groups, physics.ALL _HITS)
Returns (in a table array) all the collisionobjects that intersects a ray. May return nil or empty table if no hit at all, I’m not sure what exactly.
local hit = physics.raycast(from, to, groups, physics.CLOSEST _HIT)
Returns the closest collisionobject that intersects the ray. If no object intersects the ray, returns nil. This is what we have now.
+1
The inability to do what I am describing here makes some game mechanics (shoot, pierce, hit multiple targets) difficult, inefficient and not reliable to implement.
Just a friendly reminder that this feature very useful and deserves higher priority.
Make raycasts great again. Give them PENETRATION POTENCY.
I’ve added this as an investigation for our current sprint. No promises though!
Let’s raise this thread every month.
Let’s raise this thread every month.
The code is now in review, and should land in the 1.2.170 BETA on monday.
Sometimes it pays off to be a thorn in the side of an engine dev!
Cool! This will greatly simplify cases that are VERY difficult to solve in another way.