Object getting launched is getting stuck on the mouse cursor and following it

Welcome to our brand new Clickteam Community Hub! We hope you will enjoy using the new features, which we will be further expanding in the coming months.

A few features including Passport are unavailable initially whilst we monitor stability of the new platform, we hope to bring these online very soon. Small issues will crop up following the import from our old system, including some message formatting, translation accuracy and other things.

Thank you for your patience whilst we've worked on this and we look forward to more exciting community developments soon!

Clickteam.
  • I'm making a game with a shootable machine gun in it, but when I use "launch object" to launch a bullet in the direction of the crosshair (the crosshair is always at mouseX and mouseY), the bullets get stuck and they clump up. The bullets also follow the crosshair like a guided missile and don't go in a straight line. I want to have the bullets act like bullets and go in a straight line and go through the crosshair.

    Edited once, last by netha (August 22, 2018 at 1:29 AM).

  • I'm making a game with a shootable machine gun in it, but when I use "launch object" to launch a bullet in the direction of the crosshair (the crosshair is always at mouseX and mouseY), the bullets get stuck and they clump up. The bullets also follow the crosshair like a guided missile and don't go in a straight line. I want to have the bullets act like bullets and go in a straight line and go through the crosshair.

    Without seeing your code I'm taking a guess here and you've got them always looking at mouseX/mouseY - instead of that, you could make it so when the bullet is created the bullet's alterable values A/B are set to mouseX and mouseY and they look at those values instead. Hope that makes sense!

  • You're correct, my code has the bullet always facing the crosshair. I made the code make the bullets' A and B set to Mouse X and Y, but I don't know how to make it launch in the direction of X and Y.

  • It takes a little bit of vector math - but this is how you get the missile to always look in a certain direction (If you're using the built in movements)
    Please login to see this attachment.

    VAngle finds the angle of a vector (in this case, two points). This gives a direction in degrees, but since there are 360 degrees and only 32 directions, you have to divide it by 320/32, which is 11.25


    Here's the sample code if this makes it easier
    Please login to see this attachment.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!