Development discussion Ray.hitObjectList

Proposal

Add third type to Ray, besides xray and normal,

Continue = goes set distance, gives list of all objects it hits in order they were struck.

Use = armor piercing bullet, And filtering collision objects maybe more.

Thoughts?

Just now you need an additional hit detection (ray) for each found face. Therefore this proposal looks like a good enhancement.

I do not think it is efficient on a sensor, as a sensor mainly needs one hitObject to evaluate positive status.

You would need Python to process the dynamical part anyway. So I think the most sense is to add this as separate API call. This way a normal ray sensor can trigger a Python controller. Which may (or may not) perform further checks by retrieving all objects/faces from an additional API call (e.g. KX_GameObject.detectObjectsBetweenPositions(sourcePosition, targetPosition).

This moves the necessary processing time to the Python controller. This should enable the user to let run his logic pretty efficient.

This would be cool as it would allow for blood behind an object.
Although thinking about it (as a temporary solution) you could shoot your initial ray, and then upon hitting the object get the hit.worldPosition + (object that fired)'s rotation and spawn in a secondary empty that shoots an xray through the object, looking for an object with the property wall or floor.
Upon hit of the xray again get the hit location and the normal and then spawn in a blood splat on the secondary location.

You could also spawn in a bloodhit effect when the first ray hits the object.

Just some thoughts.

I can recast rays, I do it all the time,

It would just be more efficient to grab a whole list.

It is possible to do this, because Bullet supports ray cast trough multiple objects (AllHitsRayResultCallback).
But actually only ClosestRayResultCallback is implemented in CcdPhysicsEnvironment. There is a lot of code need to be added to get this work.
So it is fare from trivial to implement a hitObjectList for the ray.

@BluePrintRandom I was thinking about the same (for MouseOverAny, but for Ray its even better)

I’d like to enlarge your proposal: not only your Ray.hitObjectList but also Ray.hitNormalList and Ray.hitPositionList.
(Maybe even Ray.hitMaterialList though I dont know where to use that)

I like Monsters idea of that being a additional API - call, rather than a part of the sensor. It would keep the sensor slim and the game efficient. However I’d rather have it as a function inside the sensor. If it would look like this: Ray.hitObjectList([start=0.0,] end=100) it would be easy to find and intuitive.