Ray casts only work with collision caster

NOTE: All the walls are solid, the object that is having its collisions turned off is the yellow line (This is also the object casting the Ray)

Without Collision on the object sending out the Ray Cast

Screenshot 2022-09-21 9.26.18 AM

With Collisions

Screenshot 2022-09-21 9.26.08 AM

Someone give me 1 logical reason why this is. Btw I said something like this in the past, I knew I wasn’t crazy.

@grazer, I would like to to not have these objects have collisions please.


So @JR01 I guess I wasn’t wrong. Do you happen to have a logical reason for why collisions would need to be turned on and completely break my shadows that would normally run at 55 fps?

1 Like

Side note, for grazer

Emit is also limited in the number of objects it can emit. Both I and TheBrickcentric noticed this. The limit appears to be around the 200 mark

1 Like

Are you asking about solidness or collision?
Because Raycast does need collision but they don’t have to be solid.

makes sense that it needs collisions

The walls the ray casts are hitting are solid, but the object that is sending out the ray is unsolid.

Strangely, if you then disable collisions with the Enable behavior it still works

If you want you can test it out by turning off collisions in the Line object.

that runs pretty well :o

1 Like

Ty, I made a very tedious version before and thebrickccentric reminded me that there is almost always an easier way to do things so I came up with the idea of putting the ray casts in the lines instead of the player. This avoids messages and improves performance

if you make the line animation even taller, it looks less broken at a distance

1 Like

Yeah, I just have it like that because it’s slightly less accurate, but in an actual game you would just use a larger sprite because it’s not super noticeable

1 Like

I would use it if the yellow could hide another object instead, but that’s not a feature yet. Forgot what it’s called too

Here is your one (1) logic reason that an object needs to have some sort of Collision Shape in order for a raycast to hit it: If the object has no shape, what is there that the Raycast can detect?

If it is a Circle, the ray will hit the edge of the circle, If it is a Rectangle, then the ray will hit the edge of the rectangle instead. If there is no shape, the ray will hit…?

Yes, this is true. The limit is to prevent the relatively common case of emitting objects forever without having an expiration set. The limit prevents the game from lagging out & consuming vast amounts of memory when emitting lots of objects.

That being said, the limit is pretty old and could probably be safely raised.

1 Like

EDIT: Sorry to bug you again @grazer but that isn’t the question I was asking.
This is the question I was asking.

The walls are solid, which is the object the rays are hitting, but the LINE object which is casting the ray does not have collisions.

I understand why the walls need to be solid, that makes perfect sense. But why does the object CASTING the ray need to be solid?

Grazer you can see this happen if you turn collisions off on the Line object.

The object casting a ray does not needt to be solid. Objects without any physics shape can cast rays just fine. Probably what is happening is that the rays are missing because the origin of the ray is not where you would expect. Because the object has no physics, the origin is not moving as the sprite undergoes transforms like scaling/rotation.