Laser Blast Enemy

I want an enemy in my game to blast a laser and spin, making it much harder to move around and hit enemies until you kill the blaster. How would I make the laser emit and know what rotation to have?
P.S: can’t show a link since the game is private and planned to be released on steam.

Best example I can think of if you still don’t understand is that it’s something like the ghostbusters weapons.

2 Likes

You can just make the blaster attach a lazer sprite (make the lazer sprite the longest width you can get it), and put orientation on. The attach will still enable the collisions, but it isn’t solid, which kinda corresponds with reality cuz lazers aren’t solid.

1 Like

So i’d use an attacher to the object which emitted? How would I get the object which is emitted, if the enemy is spawned?

1 Like

Attacher just spawns an object and then attaches it to the creator

1 Like

Oh. Would’ve saved me time earlier. How would I attach an object then?

1 Like

image

1 Like

Using that spawns the laser in the middle, making it shoot in 2 directions (front & back), when I want it to only point forwards.

1 Like

Also it disables collisions, meaning I can’t detect anything.

2 Likes

raycast

Okay. Then what you need to do is:

  1. Go into the image editor and delete the left half of the lazer
  2. In the blaster, make a spawn behavior spawning the lazer
  3. In the lazer, make it extract the blaster position (or have the blaster set some globals) and set that as its own position
  4. In the lazer, make it constantly rotate
1 Like

Raycast doesn’t have a sprite.

2 Likes

i know i meant raycast to detect stuff

There’s going to sometimes be multiple blasters on screen, so globals won’t work, and the blasters are going to be spawned in.

2 Likes

Then…
Have the blaster spawn the lazer relatively close to the blaster position, and on start the lazer does a proximity check and then sets that as the position

1 Like

Proximity checks for the middle of objects, and since there is going to be multiple objects, the laser could contract the wrong blaster.

1 Like

Hold on lemme think…

I think I found a solution, but it requires some list work.

I got the laser working, just need the proximity to work. Why does attacher need to disable collisions?

1 Like

Idk, ask @grazer

Because if that wasn’t a problem then I could just use an attacher and this would be easy.

1 Like