Bullet Movement Issue

Get help using Construct 2

Post » Wed Sep 25, 2013 12:42 am

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.
B
9
S
3
G
2
Posts: 51
Reputation: 1,522

Post » Wed Sep 25, 2013 12:49 am

Bullet Set Angle(Character.Angle)
B
46
S
16
G
74
Posts: 2,089
Reputation: 44,187

Post » Wed Sep 25, 2013 1:23 am

@plinkie
This was the first thing I tried and it still just goes off to the right
B
9
S
3
G
2
Posts: 51
Reputation: 1,522

Post » Wed Sep 25, 2013 1:59 am

@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.
A big fan of JavaScript.
B
74
S
20
G
69
Posts: 2,215
Reputation: 43,852

Post » Wed Sep 25, 2013 2:12 am

@Colludium
unfortunately that's not the case as I did chose spawn object
Thanks though!






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.Dannyzigg2013-09-25 02:15:44
B
9
S
3
G
2
Posts: 51
Reputation: 1,522

Post » Wed Sep 25, 2013 2:43 am

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.
ImageImageImage
B
71
S
21
G
232
Posts: 3,696
Reputation: 129,868

Post » Wed Sep 25, 2013 2:47 am

@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!
A big fan of JavaScript.
B
74
S
20
G
69
Posts: 2,215
Reputation: 43,852

Post » Wed Sep 25, 2013 2:57 am

@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
B
9
S
3
G
2
Posts: 51
Reputation: 1,522


Return to How do I....?

Who is online

Users browsing this forum: blackhornet, evillair, gamecorpstudio, jorgmaquoi, ultrafop and 24 guests