Hey there guys,
While thinking of some ideas for implementing combat-related issues, I have come across numerous problems regarding collisions.
Initially discussed in this issue, I've been revolving around the idea of how to make collisions help development rather than limit it. Thus, I wanted some input and feedback on the ideas I presented there, which I'm also going to compress into a more readable structure here.
First of all, I wanted to talk about item collisions. There are no events sent when items interact with the world, making it pretty hard to implement stuff like StickyTorches, Arrows (that can embed into walls), certain types of interactions with certain blocks (like in the issue, any item and lava) or the general issue of tunneling.
A quick way of fixing this issue would be my option of adding a bit of code to the physics engine, and raytracing items that have certain components (so that we don't calculate raytraces for everything that dropped from... say... an explosion... or multiple of them *cough* railgun *cough*).
"HitResult hitResult = physics.rayTrace(location,comp.velocity.normalize(),comp.velocity.length()*delta, StandardCollisionGroup.LIQUID);
if (hitResult.isHit() == true) {
This of course manages collisions with the first item of the type it manages that it encounters in the direction of movement in the next frame. This of course is really specific, and we wouldn't want something that specific in a physics engine which should be capable of being used for pretty much any type of interaction we'd want.
As I've specified in the issue, I would like to know if it's possible for us to have a raytrace that is just distance based (instead of distance and collision group that is) that return all entities it encountered, so that we can interrogate that entity list for whatever items we are looking for at the moment. (For example, something falling straight down into water with a longer raytrace would return all the air blocks to the water, the water and the blocks beneath the water for as far as the raytrace goes).
As for the tunneling issue, we could stop really fast items from clipping through the ground by placing them just above (either stopping them or making them somehow get affected by the collision; whichever works best).
Item on item collisions I imagine would be a bit different from world collisions, as their rigidbodies would be the ones interacting rather than a directional velocity. I haven't gone deep into these but I'd love to hear some ideas on it
One more thing to add is that I found out raycast != raytrace != raymarch. From what sources I gathered raycasting would be the best use case for the issue at hand, while raymarching would prove inexact for several edge scenarios ( albeit most efficient! ), and raytracing sounded like the heaviest type by sending secondary rays with every hit (mostly used for rendering)
Pinging @Josharias and @Flo for some discussion on this subject.
While thinking of some ideas for implementing combat-related issues, I have come across numerous problems regarding collisions.
Initially discussed in this issue, I've been revolving around the idea of how to make collisions help development rather than limit it. Thus, I wanted some input and feedback on the ideas I presented there, which I'm also going to compress into a more readable structure here.
First of all, I wanted to talk about item collisions. There are no events sent when items interact with the world, making it pretty hard to implement stuff like StickyTorches, Arrows (that can embed into walls), certain types of interactions with certain blocks (like in the issue, any item and lava) or the general issue of tunneling.
A quick way of fixing this issue would be my option of adding a bit of code to the physics engine, and raytracing items that have certain components (so that we don't calculate raytraces for everything that dropped from... say... an explosion... or multiple of them *cough* railgun *cough*).
"HitResult hitResult = physics.rayTrace(location,comp.velocity.normalize(),comp.velocity.length()*delta, StandardCollisionGroup.LIQUID);
if (hitResult.isHit() == true) {
if (entity.hasComponent(SpecialComponent.class)) {
}"entity.send(new SpecialEvent());
}This of course manages collisions with the first item of the type it manages that it encounters in the direction of movement in the next frame. This of course is really specific, and we wouldn't want something that specific in a physics engine which should be capable of being used for pretty much any type of interaction we'd want.
As I've specified in the issue, I would like to know if it's possible for us to have a raytrace that is just distance based (instead of distance and collision group that is) that return all entities it encountered, so that we can interrogate that entity list for whatever items we are looking for at the moment. (For example, something falling straight down into water with a longer raytrace would return all the air blocks to the water, the water and the blocks beneath the water for as far as the raytrace goes).
As for the tunneling issue, we could stop really fast items from clipping through the ground by placing them just above (either stopping them or making them somehow get affected by the collision; whichever works best).
Item on item collisions I imagine would be a bit different from world collisions, as their rigidbodies would be the ones interacting rather than a directional velocity. I haven't gone deep into these but I'd love to hear some ideas on it
One more thing to add is that I found out raycast != raytrace != raymarch. From what sources I gathered raycasting would be the best use case for the issue at hand, while raymarching would prove inexact for several edge scenarios ( albeit most efficient! ), and raytracing sounded like the heaviest type by sending secondary rays with every hit (mostly used for rendering)
Pinging @Josharias and @Flo for some discussion on this subject.
Last edited: