CollisionRay, CollisionLine, CollisionSegment, CollisionParabola

Can anyone tell me the use and some examples of the Collision Solids mentioned in the title?

Their uses are… well, what uses you come up with for them!

Perhaps it would be more helpful to compare and contrast them:

To start with, let me mention how they’re the same: They’re all, essentially, lines–that is, they detect the intersection of a line with whatever other collision solids may be present.

Now, how they differ:

  • A CollisionLine more or less what it sounds like–a line extending off into infinity in either direction. As a result, it will detect things anywhere on that line, again in either direction.
  • A CollionRay is pretty much the same, except that it only detects things in one direction–what one might think of as “fowards”. Nevertheless, in that direction it detects things off into infinity.
  • CollisionSegment is again similar, but is even more limited: it only detects things between a start-point and an end-point; any objects beyond those points will not be detected.
  • And finally, a CollisionParabola is pretty much like a CollisionLine, except that instead of a straight line, it forms a parabola.

If you’re still struggling to come up with uses for them, then perhaps they’re simply not yet useful to you.

If you’re wondering which fits your purposes, perhaps consider the effects that I gave above: Do you want to detect things in either direction? Or merely as far as possible in one direction? Or only within a very specific range? Is a straight line appropriate to your purposes, or would a parabola fit better?

OK I understand. They basically the geometry shapes we learnt in school. But how do you construct a parabola?


So basically anything on the line will be colliding, right?
Can it be used like a CollisionCapsule to block players too?

Pretty much, yes! :slight_smile:

I’ve honestly never used a CollisionParabola that I recall, so I’m not sure. Looking at the API, it seems that you construct a Parabola object, then feed it two end-points along the course of the parabola.


(As mentioned previously, if you just want the first collision, then a CollisionHandlerQueue offers the ability to sort the collision-entries from first to last. Otherwise, you might iterate through the collision-entries and find the nearest–but that, I suspect, will be slower.)

Hum. Theoretically, yes. But if you mean to use it as “level geometry” then I don’t know how easy it would be–I don’t know offhand whether you’d get a push-response from one of these when using a CollisionHandlerPusher.

You could get collision-events from a CollisionHandlerEvent, but then you might have to implement the response to those events–stopping the player and pushing them out of the “wall”–yourself.

You can of course use a ray or suchlike to detect nearby surfaces and thus stop the player, but that tends to be less effective than using a sphere, I think.

I saw the API. the construction for a parabola says it needs 3 arguments. I think the 2 float arguments are the main ones. But what about the first argument of type LParabola? what should I pass here?

As it says: A Parabola object. To elaborate: Note that, in the API, for that parameter it says “parabola: LParabola”. The second part of that indicates the type of the parameter–in this case an object of type “LParabola”. If you click on that, you should be taken to the API page for that class, which should give you more information on what it is and how one constructs it.

The original purpose of CollisionParabola is to implement aiming of a thrown object (like a cannonball) in games, if you want to show an aim arc and need to give feedback to the player about what or where it will hit, like so:

Of course, if you can find another use for it, then more power to you!

1 Like