Laser rays that can't go through walls

I don’t know how to explain this, so I made a drawing:

If laser is in collision with wall destroy laser?

1 Like

Well, yeah but not as simple as that. I want it to work just like a laser, a ray that… goes forward and stuff and I just realized I can do that with adding a force…
…soooo yeah thx for the help

And also, what do I do with the particle? I add a Trigger once and it’s done?

Ok, new problem. I did this:



But in the preview, this happens:

You may need to set the z order for your laser when it’s created.

A good solution for this is to use an raycast for estimate the distance, the raycast return the position of a collision with an object.

http://wiki.compilgames.net/doku.php/gdevelop5/objects/base_object/events#raycast_and_collision

This has a great example of drawing a solid line that can be stopped by objects:
https://editor.gdevelop-app.com/?project=example://zombie-laser

Your code appears to create laser objects with every game cycle (60 per second). Make sure anytime you use “create object” that you use some method to control the amount of objects are created (trigger once, timer, etc)

Thanks everyone for the response, so I did this:


But, I don’t know anything about raycasting or other stuff that was mentioned, so it didn’t work.

I did a timer, but it didn’t change anything.

Didn’t work either