YesNoOk
avatar

Homing projectile issue (Read 4268 times)

Started by Liero, January 20, 2011, 11:10:34 pm
Share this topic:
Homing projectile issue
#1  January 20, 2011, 11:10:34 pm
  • **
    • http://rumblepk.tumblr.com/
This creates a projectile that follows the opponent where ever they go.

To accomplish this, a Helper must be used. If you wish to add any Projectile Effects, simply add them to this state.

Code:
[State ****: Turn]
type = Turn
trigger1 = (P2Dist X < 10)

[State ****: VelSet]
type = VelSet
trigger1 = (!Time)
x = 3

[State ****: VelAdd]
type = VelAdd
trigger1 = (P2Dist X < 0) && (Vel X > -6)
x = -0.2

[State ****: VelAdd]
type = VelAdd
trigger1 = (P2Dist X > 0) && (Vel X < 6)
x = 0.2

[State ****: VelAdd]
type = VelAdd
trigger1 = (EnemyNear, Pos Y > Pos Y) && (Vel Y < 6)
y = 0.2

[State ****: VelAdd]
type = VelAdd
trigger1 = (EnemyNear, Pos Y <= Pos Y) && (Vel Y > -6)
y = -0.2

I'm using a variant of this code for homing projectiles, but the projectiles always go towards the target's feet.  Is there a way to have it target higher up (preferably around the torso area)?
Re: Homing projectile issue
#2  January 20, 2011, 11:13:46 pm
  • avatar
  • ****
maybe Y should be something like this

y=-20
or
y=-50
Re: Homing projectile issue
#3  January 20, 2011, 11:19:21 pm
  • **
    • http://rumblepk.tumblr.com/
Those are "veladd" controllers, not "posset".  Either one of the values that you gave me would make them fly incredibly fast instead of locking on the player's torso.
Re: Homing projectile issue
#4  January 20, 2011, 11:43:32 pm
  • avatar
  • **
  • Nerdy artist & gamer.
This should keep the helper's velocity at 3, while still homing in on the nearest enemy's torso:

[State 0, VelSet]
type = VelSet
trigger1= 1
x = 3*((EnemyNear(0),const(size.mid.pos.x)-const(size.mid.pos.x))*Facing)/(fvar(12):=((((EnemyNear(0),Pos X-Pos X)*Facing)**2)+(((EnemyNear(0),const(size.mid.pos.y))-const(size.mid.pos.y))**2))**0.5)
y = 3*((EnemyNear(0),const(size.mid.pos.y)-const(size.mid.pos.x))/fvar(12)

Edit:
This should be able to replace all of the original code regarding the velocity.
Last Edit: January 21, 2011, 12:03:03 am by hogaraka
Re: Homing projectile issue
#5  January 20, 2011, 11:51:36 pm
  • avatar
  • ****
the numbers were a little high but it would still work
Re: Homing projectile issue
#6  January 21, 2011, 12:38:49 am
  • **
    • http://rumblepk.tumblr.com/
This should keep the helper's velocity at 3, while still homing in on the nearest enemy's torso:

[State 0, VelSet]
type = VelSet
trigger1= 1
x = 3*((EnemyNear(0),const(size.mid.pos.x)-const(size.mid.pos.x))*Facing)/(fvar(12):=((((EnemyNear(0),Pos X-Pos X)*Facing)**2)+(((EnemyNear(0),const(size.mid.pos.y))-const(size.mid.pos.y))**2))**0.5)
y = 3*((EnemyNear(0),const(size.mid.pos.y)-const(size.mid.pos.x))/fvar(12)

Edit:
This should be able to replace all of the original code regarding the velocity.

Thanks for your help so far, but this code crashes the game.  Specifically, the "x" line gives a  parsing error and the "y" line on its own just crashes it.
Re: Homing projectile issue
#7  January 21, 2011, 01:15:33 am
  • avatar
  • **
  • Nerdy artist & gamer.
Thanks for your help so far, but this code crashes the game.  Specifically, the "x" line gives a  parsing error and the "y" line on its own just crashes it.


OK, I was way off. This should work now... ;)

[State 0, VelSet]
type = VelSet
trigger1= 1
x = (3*(P2BodyDist X*Facing)/(fvar(12):=(((P2BodyDist X*Facing)**2)+((P2Dist Y+(EnemyNear(0),const(size.mid.pos.y))**2))**0.5))
y = (3*(P2Dist Y+(EnemyNear(0),const(size.mid.pos.y))/fvar(12))



Spoiler: If not... (click to see content)
Last Edit: January 21, 2011, 10:51:32 pm by hogaraka
Re: Homing projectile issue
#8  January 21, 2011, 01:16:52 am
  • avatar
  • ****
y = -0.2 <-----this

Is that range related for the vertical nearness of the projectile to P2

What happens when you change the numbers a little

2OS

Re: Homing projectile issue
#9  January 21, 2011, 07:29:05 am
  • ****
  • 608 Wannabe
  • Ich schicke dich zur HOELLE!! STIRB DU FEIGLING!!
    • Egypt
Re: Homing projectile issue
#10  January 21, 2011, 07:44:36 am
  • **
  • Enigma
I thought of something simple  :)
Code:
[State 0, VelSet]
type = VelSet
trigger1 = 1
x = ((P2Dist X)*0.03)
y = ((P2Dist Y+Const(size.mid.pos.y))*0.03)

Como Hacia Hitler Mijo

2OS

Re: Homing projectile issue
#11  January 21, 2011, 07:51:02 am
  • ****
  • 608 Wannabe
  • Ich schicke dich zur HOELLE!! STIRB DU FEIGLING!!
    • Egypt
^ Won't work if the character crouches or lies down, mine is so that it does
Re: Homing projectile issue
#12  January 21, 2011, 08:02:16 am
  • **
  • Enigma
^ Won't work if the character crouches or lies down, mine is so that it does
thx ;D
update  ;D
Code:
[State 0, VelSet]
type = VelSet
trigger1 = 1
x = ((P2Dist X)*0.03)
y = ((P2Dist Y+Const(size.mid.pos.y))*0.03)+((enemynear,statetype=C)||(enemynear,statetype=L))

Como Hacia Hitler Mijo

2OS

Re: Homing projectile issue
#13  January 21, 2011, 09:18:56 am
  • ****
  • 608 Wannabe
  • Ich schicke dich zur HOELLE!! STIRB DU FEIGLING!!
    • Egypt
You're trying too hard at this point


1. VelADD, not VelSET, Velset for a homing projectile will home to enemies rather unfairly

2. I've tested your bits against various works, it homes to the enemy's head, rather than the enemy's torso, unless the enemy character is ridiculously tall [ EG. Hugo, EarthQuake ]

3. Speed is WAY too fast IMO


I'm gonna kindly ask you to quit trying to ""correct"" me as if you're under the impression that I don't know what the fuck I'm doing
Re: Homing projectile issue
#14  January 21, 2011, 04:22:05 pm
  • **
  • Enigma
 :???:

1- is for helper not proyectile ;)

2- I forget the enemy redirection for const

3- the velocity you can modify dude ....
;--------------------------------------------------------

I was thinking team arcade...
if you want to look for the nearest opponent, as long as it is active velset
Code:
[State 0, VelSet]
type = VelSet
trigger1 = 1
x = ((EnemyNear,Pos X - Pos X)*facing/20)
y = ((EnemyNear,Pos Y - Pos Y+EnemyNear,Const(size.mid.pos.y))/20)+((EnemyNear,statetype=C)||(EnemyNear,statetype=L))

and for one enemy  ;)
Code:
[State 0, VelSet]
type = VelSet
trigger1 = 1
x = ((Enemy,Pos X - Pos X)*facing/20)
y = ((Enemy,Pos Y - Pos Y+Enemy,Const(size.mid.pos.y))/20)+((Enemy,statetype=C)||(Enemy,statetype=L))

Como Hacia Hitler Mijo
Last Edit: January 21, 2011, 09:35:47 pm by -True-
Re: Homing projectile issue
#15  January 22, 2011, 12:48:48 am
  • **
    • http://rumblepk.tumblr.com/
"veladd"
x=p2bodydist x/2000
y=(p2bodydist y-25-50*(enemynear,statetype!=c&&enemynear,statetype!=l))/2000

This is pretty close to what I wanted.  The y axis calculation is pretty much exactly what I wanted, but I ended up keeping my own x calculation as yours' didn't really have the effect I was looking for.

:???:

1- is for helper not proyectile ;)

2- I forget the enemy redirection for const

3- the velocity you can modify dude ....
;--------------------------------------------------------

I was thinking team arcade...
if you want to look for the nearest opponent, as long as it is active velset
Code:
[State 0, VelSet]
type = VelSet
trigger1 = 1
x = ((EnemyNear,Pos X - Pos X)*facing/20)
y = ((EnemyNear,Pos Y - Pos Y+EnemyNear,Const(size.mid.pos.y))/20)+((EnemyNear,statetype=C)||(EnemyNear,statetype=L))

and for one enemy  ;)
Code:
[State 0, VelSet]
type = VelSet
trigger1 = 1
x = ((Enemy,Pos X - Pos X)*facing/20)
y = ((Enemy,Pos Y - Pos Y+Enemy,Const(size.mid.pos.y))/20)+((Enemy,statetype=C)||(Enemy,statetype=L))

This works, but not exactly what I wanted.  Thanks anyways though!