Help with making object width

um Idk how to make it so the object goes width goes to a distance of object.X(and y) and raycast end well it isn’t working how I thought it would at least)

The idea of a raycast is that you check whether it’s hit any of the objects it’s being checked against. You do this by having a subevent that has the condition “Number of [object] > 0”.

Inverting a raycast makes no sense. I understand what you’re trying to achieve, but inversion isn’t the way to do it. You want the light to be 96 pixels wide unless it hits a block, in which case it’s as wide as the distance to the block.

Here’s a way of doing it :

ive tried this and it doesnt work, also doesnt inverting means it will do the furthest one in the ray

Sorry, my bad - I don’t know why that inversion is in there. It shouldn’t be inverted at all.

ooh okay, it does the same thing as what my one does then(but it looks nicer), btw I tested it without the invert to

Is there a reason you’re using a sprite? Changing sprite and widths when they’re rotated doesn’t work the way you’d expect - when you rotate, width is still left and right, it doesn’t change with the rotation.

Have you looked into drawing a line instead (using a Shape Painter?

I haven’t looked into using shape painter but I’ve thought about using it(I’m to afraid to since I’ve never really done it before) but if I try the Tiled sprites would it work then?

okay i tested and as far as I can say its no, so uh how would I use the shape painter for it?

okay i got a basic thing setup with it

but this is as far as ik with shape painter

edit:I figured out a system for it

only 1 issue now, and that’s cuz there’s only 1 raycast(if i add more it don’t work to though)

I’m asuming that issue is that the light pushes through the block when the enemy is to the side of the block?

If so, that’s because the raycast is a single thin line, while the light is a thick, fat line. You could get around this by firing 3 parallel raycasts, one for each of the left, middle and right part of the light. If any of the 3 raycasts hit something, then shorten the light.

1 Like

this wouldn’t work the way i have it, i did test before i asked, but ill try again after i wake up from sleep