I'm creating a shooter type of game for my first assignment.

The enemy moves randomly across the screen and I want the projectiles to fire from it's current position.

As of now, the projectile continues to fire from the position it was first created and updates x,y position randomly instead of each time it's created.

I've tried many combinations of updating the x,y position, but haven't had any luck.

This is what my projectile code looks like with 2 of my attempts at updating x,y position. This is what my projectile code looks like

2 Answers 2


The script at the lower left looks bad. Not only it is an infinite loop without any waits, also it doesn't make sense to me.

Maybe update the Crab_xpos and Crab_ypos variables whenever you move the crab sprite, or whenever you spawn a projectile.

Also, you cannot change x and y of the clone after you created it, at least not where you try to do it. Either change it before cloning (so the clone inherits the changed properties, I think that's how it works), or set those in the "when I start as a clone" part, before pointing towards Cat.

  • Haha, that was my desperate attempt to get something to work. I think I have to adjust more than my projectile script. The crab movement might be in a loop until it's dead, which could be the cause of the projectile position not updating? Thanks for your help!
    – rcs50
    Jul 25, 2018 at 1:34

Update: I've got it working now after following the suggestion of setting the variables in the "when I start as a clone" block.

Here is the code for getting the position of the enemy so the projectile could spawn from it:

enemy position

And here is the code for the projectile position:

projectile position

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .