YesNoOk
avatar

Homing Jump Attack with Adjusted Velocity (Read 2215 times)

Started by BoyBoyz, January 15, 2018, 03:48:46 pm
Share this topic:
Homing Jump Attack with Adjusted Velocity
#1  January 15, 2018, 03:48:46 pm
  • ***
Hi, I need help making a character jump toward the enemy, and along the jumping trajectory, depending on how far the enemy is, the velocity is adjusted accordingly.  E.g. if enemy is near, I will complete the arc nicely without too much vel x / vel y, but if enemy is full screenlength away, I will jump very fast toward enemy.

I'm not very good with coding so if you could paste a chunk of code to get me started I would be v grateful.  Thanks!

If unsure of what I'm talking about, just see 11.35 onward of the vid below (the character I'm trying to make).

Last Edit: January 15, 2018, 03:52:22 pm by BoyBoyz
Re: Homing Jump Attack with Adjusted Velocity
#2  January 15, 2018, 04:14:10 pm
  • *****
  • Shame on you!
    • USA
vVv Ryuko718 Updated 10/31/22 vVv
Re: Homing Jump Attack with Adjusted Velocity
#3  January 15, 2018, 05:12:36 pm
  • ****
  • Robotics Engineer
    • USA
    • altoiddealer@gmail.com
Not sure if this is helpful to what you are requesting...

DEMAN provided me with a code snippet awhile back, to arc from 1 point to another in a fixed amount of time.  So regardless of distance, it makes a nice smooth arc with the appropriate x/y velocity to get there in the specified timeframe.

In the code below, this is from a Helper "projectile" with the enemy's head as the target, in 75 ticks.  Adjust the 75 to your taste, and change 76 so it is 1 higher than the former value.
Physics was "N" for this helper, btw.  So if you use this code you may want to temporarily change physics to N as well.

Code:
[State 1851, Cork fly]
type = VelSet
trigger1 = Time = 0
x = (Abs(Enemynear,pos X - pos X)) / 75
y = (((0.5*Const(movement.yaccel)*75*76)-((Enemynear,Const(Size.Head.pos.y))-(pos Y)+(Enemy,pos Y))) / -75)

Last Edit: January 15, 2018, 05:17:07 pm by altoiddealer
Re: Homing Jump Attack with Adjusted Velocity
#4  January 15, 2018, 05:34:53 pm
  • ***
Thanks guys!! Both work !!