Laser Behavior (Like In Boss Fights) [SOLVED]

I want to create an enemy that shoots a laser beam like this:
image
My first attempt is to use raycast but I can’t understand it well so I decided to use a long laser sprite instead. But the problem is that when it rotates, the laser rotates in the center so it will looks like this:
image
Is there a way that the laser will rotate in the body of the enemy just like this:
image
Or if not, My only objectives is to make an enemy that shoots solid laser like this and can be rotated just like the enemies in boss fights were it shoots solid laser that rotates. Any idea to do this even if it’s raycast is accepted but I need exact solution on how to do it. Thanks in advance.

1 Like

maybe adding a point on the player where you what the laser to come from and than move the center point of the laser at end in middle where it will rotate from.

5 Likes

Can you elaborate more or show example? I couldn’t understand what you were suggesting.

This one is a perfect use case for the shape painter and a raycast, like you originally thought.

Check out the “zombie laser” example in the engine. It does what you are looking for.

1 Like

I did test you can edit the origin point of the enemy to be in the center

for the laser adjust both origin and center points to be at the end in center

events

you can add a separate object over the enemy so laser rotates independent of the enemy angle.

1 Like

I didn’t know that you can change the center of the object and now it actually works! Thanks!

1 Like