YesNoOk
avatar

Velset towards the opponent (Read 1529 times)

Started by nissouma55, November 23, 2017, 06:23:06 pm
Share this topic:
Velset towards the opponent
#1  November 23, 2017, 06:23:06 pm
  • *
Hi everyone,
Again, u can see how my mugen coding skills suck, so much that I have been stuck for days trying to figure this thing out...
Well... I would like to make it so that my projectile goes toward the enemy, its not a homing projectile it just shoots toward the enemy s position without following him if he moves or dodge or something. Tryed using p2Dist X and p2Dist Y for this but sometimes it doesnt work and even if it does its not always at the same speed like if p2 is close to the projectile before it velsets it gets faster... Thats not what I want, I want the speed to be constant regardless of the p2 s position. So help please :/

Thanks

Here is my helper: (Didnt add hitdef yet)
Code:
[statedef 20002]
type = U
movetype = A
physics = N
velset = 0,0
anim = 20002

[State 0, PlaySnd]
type = PlaySnd
trigger1 = time = 0
value = S8,0

[State 0, Turn]
type = Turn
trigger1 = animelem = 5 && enemy, pos X < pos x
;ignorehitpause =
;persistent =

[State 0, VelSet]
type = VelSet
trigger1 = time = 21
x = P2DIST X
y = P2DIST Y
Last Edit: November 24, 2017, 10:56:09 pm by nissouma55
Re: Velset towards the opponent
#2  November 25, 2017, 08:26:56 am
  • ******
  • Legendary XIII
  • I am the eye of the storm to come!
    • New Zealand
    • network.mugenguild.com/cyanide/
You may have already worked this out but the code library has the following

Code:
    [State ****: Null]
    type = Null
    trigger1 = (!Time)
    trigger1 = (FVar(0) := (P2Dist X * 10) / (Exp(0.5*ln((P2Dist X * P2Dist X) + (P2Dist Y * P2Dist Y)))))
    trigger1 = (FVar(1) := (P2Dist Y * 10) / (Exp(0.5*ln((P2Dist X * P2Dist X) + (P2Dist Y * P2Dist Y)))))
     
    [State ****: VelSet]
    type = VelSet
    trigger1 = (Whatever)
    x = FVar(0)
    y = FVar(1)

Alter the velset by multiplier if you need more or less speed.


In M.U.G.E.N there is no magic button

They say a little knowledge is a dangerous thing, but it's not one half so bad as a lot of ignorance.
Re: Velset towards the opponent
#3  November 25, 2017, 04:30:10 pm
  • *
I used a similar method, I worked this out with some maths...
Thanks Cyanide, your help is appreciated.