Issue with bullet behaviour

0 favourites
  • 3 posts
From the Asset Store
This pack contains 10 types of bullet effects, with different shapes and colors.
  • Ok so I'm a beginner and I've started making a game where the character is able to dash towards the cursor, but I'm having this issue where the character moves right or left (depending on which side of the character my cursor is) at the start of the dash, then starts moving in the direction it's supposed to (I'm using the bullet behaviour) The amount that it moves right/left scales with the speed I've set it to (higher speed means it moves further before going where I want it to) so I'm assuming the problem is that it starts moving before setting the angle of motion but I haven't set it that way in the code and I don't know anything about this.

    My code is as follows:

    or in case the link doesn't work:

    imgur.com/6kvxmSl

    Does anyone have any ideas of what might be the problem and/or how to fix it? Thanks in advance!

  • Its not very clear from your description, but is there any reason you're using an intermediate instance variable to store the sprite angle to set the dash angle? I assume the bullet behavior speed is normally 0 or disabled outside of dashing, and dashing always happens towards the mouse. The problem might have to do with which the order in which you set the sprite angle, take that and save it to its instance variable, and have the bullet angle set towards the instance variable value every frame. The first frame upon dashing may not have received an updated angle until the following frame, which may cause some irregularities. Try simplifying it to only set the angle towards mouse position during the dash event - set bullet angle to "angle(sprite.x, sprite.y, mouse.x, mouse.y)". This expression gives you the angle between the sprite position and the mouse position.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Well, that was kind of the trouble to begin with. I originally had it how you suggested, so having it directly set the bullet angle of motion to the angle between the Sprite and the mouse cursor, but it didn't end up changing the angle of motion at all - or more specifically it would set it to either 180 or 0 depending on which it was closer to. So I did the thing with the instance variable to stop this from happening. I also ran an experiment where I had it wait a set time before starting the movement (so after it had done all the bullet angle setting and that) and it still had the problem, so I don't think it's that.

    Thanks for the reply though, sorry it didn't help.

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