Gravity-Bound Projectiles that Trace Position

Get help using Construct 2

Post » Wed Jun 08, 2016 12:43 am

In some games, such as Mega Man (again), there are some enemies that have the ability to fire shots that somehow manage to both get your X position and yet at the same time throw shots in an arc.
https://youtu.be/aZMXvt1kppc?t=1m36s

Is there any way to possibly emulate this in Construct 2 (either using behaviors or purely through events)?
B
28
S
14
G
6
Posts: 29
Reputation: 5,457

Post » Fri Jun 10, 2016 11:44 pm

maybe every tick create a track sprite at object.x and object.y?
https://www.ravenheart.ca/home
Company name changed to avoid Facebook-type shenanigans

"Someone once told me I bite off more than I can chew...

I told them I would rather choke on greatness than nibble on mediocrity."
B
22
S
6
G
1
Posts: 1,415
Reputation: 4,824

Post » Sat Jun 11, 2016 2:21 am

What gumshoe said pretty much...

Every tick; (or every X seconds for a slower angle correction)
- Set angle of projectile.sprite towards player.X,player.Y

On "enemy shoot"
- create projectile.sprite at enemy.X,enemy.Y
- set angle of projectile.sprite to (something not already aimed towards the player - maybe straight up?)

Note, the faster your projectile and the slower it angles itself will all affect the arcing motion.

~Sol
Tired of crappy file hosts that are crappy? Get DROPBOX - https://db.tt/uwjysXJF
Moderator
B
83
S
34
G
40
Posts: 3,032
Reputation: 30,474

Post » Sat Jun 11, 2016 2:48 am

there have been other topics for that. The equations for the motion of a falling projectile is this:

y1=y0+vy*t+0.5*gravity*t^2
x1=X0+vx*t

X0,y0 is the start position
X1,y1 is the end position
Vx,Vy is the velocity
t is time

If you pick a time and then solve those equations for vx and vy that would do it.

I think it's referred to elsewhere as predictive aiming. You could also Google kinematics for more tutorials about the equations used.
B
92
S
32
G
107
Posts: 5,274
Reputation: 69,959


Return to How do I....?

Who is online

Users browsing this forum: David181, HellMax, OBLIVION and 49 guests