How do I make a bullet shoot at the cursor?

0 favourites
  • 6 posts
From the Asset Store
Mouse cursor is something that the player controls and sees all the time, that's why it is so important to make it cool!
  • Im making a game where i want the bullets to shoot at the cursor. Im not going to have a gun. the bullets should come out of the player. And i cant find a tutorial on how to do that.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • figured it out: bullet, set angle toward position: X: Mouse.X, Y: Mouse.Y

  • On the action where you spawn the bullet, add another action using the bullet object 'set angle toward position' and set the values to mouse.x and mouse.y. You will need to add the Mouse object to the project also before doing this.

  • Yeah I've had zero luck with this also. What lionz recommends sets the angle of the bullet SPRITE, but does not change the angle of motion.

    If you try to change the angle of motion, the script only allows for a single number (angle), and won't let you input Mouse.X and Mouse.Y.

    It seems that spawning a bullet, the bullet will match the angle of the object that spawned it and travel in the direction (that's how it works in the Ghost Hunt tutorial). I've yet to figure out how to take a stationary object and spawn a bullet that flies towards the pointer.

  • Yeah I've had zero luck with this also. What lionz recommends sets the angle of the bullet SPRITE, but does not change the angle of motion.

    If you try to change the angle of motion, the script only allows for a single number (angle), and won't let you input Mouse.X and Mouse.Y.

    It seems that spawning a bullet, the bullet will match the angle of the object that spawned it and travel in the direction (that's how it works in the Ghost Hunt tutorial). I've yet to figure out how to take a stationary object and spawn a bullet that flies towards the pointer.

    What I suggested works if you have 'set angle' ticked on the bullet properties, which is the default. If you unticked then it won't work, it will just change the angle of the object and not the angle of motion with it.

  • What I suggested works if you have 'set angle' ticked on the bullet properties, which is the default. If you unticked then it won't work, it will just change the angle of the object and not the angle of motion with it.

    Huh. You're right. I think my problem was that I was spawning an object that was not previously in the layout, and there didn't appear to be any way to "check" that box with just the code (maybe I'm just overlooking it). Without making any changes to my code, I just dragged an instance of the bullet into the layout, and everything started working correctly. Thanks!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)