Projectiles not spawning in the correct position


I am making a space shooter game.

You are able to shoot lasers at the enemies. The lasers spawn correctly for the player, but don't for the enemies.

I notice that the red lasers spawn with the correct direction, but always spawn at point 0, 0 (in clipspace i guess?). I think it may be because the script where it gets launched (for the enemies) is inside a "when I start as a clone" block.

Here is the code for the launching of lasers

player ("pro" is a costume of the laser, which stands for "protagonist")
the variables x and y inside the variable set commands are variables of the player
enemy clone ("ant is a costume of the laser, which stands for "antagonist")

The SET X TO X in the player version doesn't do anything, because it's the laser's X in both cases. So you aren't moving the laser.

In the enemy case, you are setting the laser's position equal to the enemy's position, because the input X is outside the gray ring, and so it's evaluated in the enemy's environment.

So I'm a little surprised that it's the player one that's working for you.

But, I don't really understand the structure of your code. The player and enemy each have a laser costume, plus there's a laser sprite that has both costumes.

Oh hang on, the enemy doesn't have a sprite variable X; it's running a script that has a script variable X, which it sets first thing to a random value. And sure enough, that's where your laser is appearing.

i was trying to make the sprite/clone make another clone with a laser costume, and I would add another "when I start as a clone" script to check if its a laser costume and do what it's supposed to do accordingly.

Then, what is the "laser" sprite for?

oh cool thanks for making me acknowledge that, now my project works
oh nevermind now the when a clone fires a laser, it gets destroyed

how do you detect which object an object is touching without using "my neighbors?"

There's a TOUCHING? predicate in Sensing. You could say
(But it'd be a little faster if you liked MY NEIGHBORS.)