OnCollision Output

I put together the Object Hit Script and am getting the outputs well:

One thing I thought of to note is that with cubical objects and box colliders the detection we experience is nearly perfect (i.e.; flat edges line up); however, if we were to use more customized objects created in 3D modelling software for example - of course depending on what kind of colliders / combinations of colliders were then attached to those obstacles (though in most cases we wouldn’t want to use mesh colliders unless absolutely necessary given that means additional computation and a slower game) - there will likely be gaps of ‘white space’ where a rigidbody hits a collider that to the player would seem to be in thin air. Just something to keep in mind as a consideration of tradeoffs between performance and accuracy when designing games that I think its good to note.

Anther thing I ended up thinking of during this process was the possibility of attaching the ‘ObjectHit’ script to a parent container for the obstacles in question. As suspected this didn’t detect collisions with the children obstacles underneath - and after consideration the last thing I think would be wanted would be to limit modularity by creating a giant mesh (not to mention needing to be continually modified) on the parent container object to detect collisions or to (if even possible without trying to create and refactor a whole new OnCollsionEnter script on your own) try to modify the collision detection in code to detect collisions with children (which would likely also be less performant than having the detection on the individual children - given their would be no extra need to to find reference objects in addition).

In the end I have to thank unity’s capabilities for allowing drag and drop to multiple highlighted objects at once that made the process convenient. In the future as a lesson learned what I would do, even if I was using temporary placeholder wall objects, would be to create a prefab of an initial wall first (with the script attached) before adding a bunch of them first like I did this time.

Privacy & Terms