Open Wuzzy2 opened 2 years ago
I use raycasts to predict whether the parachute object would collide with anything before actually spawning it.
What you actually want is checking whether a box would collide with any other boxes which is exactly what https://github.com/appgurueu/disable_build_where_they_stand/blob/master/init.lua does using only Lua; it was quite a hassle to implement (I had to implement all possible node collisionbox types, but that code resides on modlib, keeping dbwts simple).
Like appguru said instead of extending raycasts to do this what you really want is pretty much invoking the engine's collision detection once, basically calling collisionMoveSimple
.
Ignoring my specific use case, is this feature request OK? If not, close.
There are other use-cases for this than parachutes. I.e. if I want to make an arrow, or some other projectile, I'd want to do a small raycast in each server-step, from old pos to new pos. This should use collision boxes. Edit: Also: beam weapons obviously. pew pew
I'd want to do a small raycast in each server-step, from old pos to new pos.
This is exactly what collision detection does, we should be exposing that.
beam weapons obviously. pew pew
technically this is an usecase for an infinitely small beam but also collision detection can cover this.
Problem
Currently, raycasts can only "collide" with selection boxes but not collision boxes.
Solutions
Add a new parameter or parameters to the raycast functions to control which type of "boxes" the raycast collides with (so: selection box only, collision box only, or both).
Background
I noticed this limitation when I was reworking the parachute in Repixture. I use raycasts to predict whether the parachute object would collide with anything before actually spawning it. This works for most nodes but it fails for fences which have an overhigh collision box (1.5 nodes high) but a smaller selection box (1 node high).