Bullet Movement Issue

0 favourites
  • 8 posts
From the Asset Store
This pack contains 10 types of bullet effects, with different shapes and colors.
  • So I have been trying very hard and so incredibly stuck on something that I think is so simple.

    I want a bullet to shoot from the direction my character is facing. The character moves in 8-directions but with custom movement, not the original arrow keys. Also the character has a different animation that plays based on the direction he is going.

    However every time I hit the command assigned to shoot, the bullet always goes right.

    I have tried so many things and it seems like not matter what the system can not get my characters angle. I have the "set angle" for 8-direction off, as well as the bullet behavior, and have tried different combinations with no luck. I have looked around on the forums and tried the solutions found here and nothing worked, mostly because a lot of the results were geared to a platform setting. I have tried making an instance variable "previousx and PreviousY" and set for every tick to set them as the character's X and Y then using that variable to determine the characters angle of motion then setting the bullets angle to that and still it just goes right.

    I am sure that I could set a variable to assign direction with every key I have assigned for new movement, but that seems overly redundant.

    I did try setting bullet angle to angle(character.x, character.y, mouse.x, mouse.y) This worked in setting the angle but I really want the bullet to go from the characters direction, not to mention then the bullet follows the mouse and that's just silly.

    I would love to just set the bullets angle of motion to the characters angle, like character.angle, but no matter what it never seems to have his actual angle and I don't know why.

    I know this has to be something so simple that I just haven't thought of yet.

  • Bullet Set Angle(Character.Angle)

  • This was the first thing I tried and it still just goes off to the right <img src="smileys/smiley19.gif" border="0" align="middle" />

  • Dannyzigg,

    I'm guessing what you've been doing here. Instead of having your character Spawn the bullet use the System Create Object instead.... The Spawn command causes the new object to inherit its parent's characteristics and that overrides (by design) any changes you try and make at the same time.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Colludium

    unfortunately that's not the case as I did chose spawn object <img src="smileys/smiley19.gif" border="0" align="middle" />

    Thanks though!

    <img src="http://imageshack.us/photo/my-images/833/wp50.png/" border="0" />

    <img src="http://imageshack.us/photo/my-images/560/j3lv.png/" border="0" />

    This is what I have for my movement and then shooting. I put both "set angle" and "set angle of motion" in there just to show I have tried them both, separately and together. Best I can think of is that the system isnt getting my characters angle but I don't know why.

  • Your images aren't showing, but you said you turned angle off for 8-direction, so your angle is never changing from the default, which is facing right! Either use an invisible sprite and turn the angle back on and pin your actual visible sprite to the invisible 8-direction sprite, or keep track of your own angles, based on your custom controls.

  • Dannyzigg,

    I advise you to have a read of the manual page 115 (https://www.scirra.com/manual/115/sprite)

    You misunderstood my previous post - try changing the "Spawn Object" in your event sheet to a "System/Create Object". I don't see any angle change for the Danny sprite on your event sheet - and with a Spawn Object the bullet will be created with the same angle.

    A System/Create Object will allow you to set whatever parameters you wish for the bullet. I also advise that you set the bullet's parameters AFTER you have instructed the system to create it, otherwise the system won't have an object to put the settings onto and you'll continue to get default settings for the bullet.

    Hope this helps!

  • blackhornet

    HEY! I was just trying to do something like that! Only I was pinning my invisible sprite to the character which obviously wasn't solving anything. Tried your method and it fixed the problem! Thank's a lot man!

    I knew it was something so simple. I should have known this <img src="smileys/smiley3.gif" border="0" align="middle" />

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