Bullet movement

New releases and general discussions.

» Tue Mar 18, 2008 6:24 pm

Suggestions for bullet movement, gravity.

When my bullets are shot out I want them to curve slightly for extra realism! Sort of like in soldat.
Scirra Founder
B
181
S
42
G
34
Posts: 4,438
Reputation: 54,809

» Tue Mar 18, 2008 6:34 pm

You can already do this with events. try:

if angle is greater or equal to 90
if angle is less than 270

Rotate clockwise 1 degree

if angle is greater or equal to 270
or
if angle is less than 90

rotate clockwise 1 degree

That should work. You might have to use three events instead, with:

angle less than 90 and greater than or equal to 0 -> rotate clockwise 1 degree
and
angle greater or equal to 270 and less than 360 -> rotate clockwise 1 degree
Moderator
B
96
S
34
G
33
Posts: 3,007
Reputation: 27,921

» Tue Mar 18, 2008 6:57 pm

That would make a circular curve, which might be OK, but isn't a parabolic curve like you would get in real life. An easy way to do that would just be to apply a downwards acceleration to the bullet via events, eg:

+ Always
: Add 100 * TimeDelta to 'YVelocity'
: Set bullet Y to .Y + 'YVelocity'
Scirra Founder
B
414
S
245
G
92
Posts: 25,198
Reputation: 200,337

» Tue Mar 18, 2008 7:07 pm

Good point
Moderator
B
96
S
34
G
33
Posts: 3,007
Reputation: 27,921

» Wed Mar 19, 2008 9:12 am

Thanks for a solution, but would it not be easier to have this as a checkbox and text field parameter to be easier to apply?
Scirra Founder
B
181
S
42
G
34
Posts: 4,438
Reputation: 54,809

» Wed Mar 19, 2008 12:20 pm

And a "do my game for me" checkbox maybe?

I'm just kidding, but consider that what you suggested it's really elementary coding.. then we would need a million checkboxes for ANY possibility of things happening in videogames..
B
2
S
1
G
5
Posts: 70
Reputation: 1,540

» Wed Mar 19, 2008 12:47 pm

No, I think it's a valid suggestion. You can do bullet accuracy in events too, but it's a pain and you need to know how to adjust an angle by a random amount. It's a logical addition to the bullet movement.
Scirra Founder
B
414
S
245
G
92
Posts: 25,198
Reputation: 200,337