How do I "stop" a bullet object which is following the mouse?

0 favourites
  • 3 posts
From the Asset Store
Hand-painted tiles, objects, animated objects, and background to build a colorful Mayan civilization environment.
  • Hey folks! I had great success looking for help here, the last time I needed it for this same project, so I hope someone can help me out again. A little bit of background info - I am still very new to coding and Construct 3 so I will do my best to explain everything properly. The project I am working on is a commission and I don't have permission from the commissioner to share the project or screenshots(there is a very long, insane story of how I came to be working on this project to begin with), but I will provide pseudo code and sneaky snips if possible xD

    Ookay, the issue revolves around the main directional/movement controls for the game - the game is a vertical scroller/runner, and the "project manager" wants the main character (which is a spriter object and a pinned sprite object that follows the player for extra collision detection options) to follow the mouse... but not exactly. Since it's a runner, he wants there to be a bit of a delay in the movement for the character to follow - not stuck to the mouse - I have it set up as a bullet with a speed of 100. In my event sheet I have the following events;

    System> Compare: distance(character.x,character.y,mouse.x,mouse.y) > 40 [AND] Character> booleanIsRunning (I have other booleans for wipeouts and gameOver) ... Character> Set bullet speed 100, Set bullet angle to angle(character.x/.y,mouse.x/.y)

    my next event was INTENDED to have the player stop setting it's angle towards the mouse and stay put there until the mouse is outside of 40 pixels again, but instead he is hovering around the mouse, bouncing back and forth within the 40 pixels

    System> Compare: distance(character.x/.y,mouse.x/.y) <= 40 [OR] Character> XbooleanIsRunning(X=inverted) ... Character> set bullet disabled

    I'm sure those of you who understand the bullet behaviour more can see my mistake straight away... I was considering that the bullet behaviour might not be the best method to achieve what I want here. I have an "AI" character in the game that fights the main character and I am having a similar issue with him - he is a bullet as well and when he "wipes out" the bullet still keeps him moving around on the screen. So we may be able to kill two cyberbirds with one bugfix ;)

    Thank you, brave soul who attempts to help me, in advance and let me know if there's any extra info I can provide to make it easier/clearer!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • System> Compare: distance(character.x,character.y,mouse.x,mouse.y) > 40 [AND] Character> booleanIsRunning (I have other booleans for wipeouts and gameOver) ... Character> Set bullet speed 100, Set bullet angle to angle(character.x/.y,mouse.x/.y)

    So, based on the info you could provide, basically, you could just add a "Else" after that block of code.

    The intended behaviour is just to move and stop the character. So, using "Else" means that whenever any of the "moving" conditions aren't met, it should stop.

  • O.M.G. it was so simple D: Thank you so much influogames !!! I've even learned about 'Else' statements in javascript and I just didn't think to look for that in Construct!

    It solved the bobble for my character (I also ended up setting the bullet speed to 0, too, instead of disabling the bullet behaviour), but the issue may be a little harder to solve for the AI character lol. His collision events are the issue and they aren't triggered in a way that would work with an else statement. I will probably create a separate topic for that since it isn't really related to this one (only the bullet behaviour).

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