News:

MFG's Character of the Month: October 2026 Nominations

Main Menu

Make helper stay relative to a position while moving

Started by SaltAddict, August 16, 2016, 09:24:38 PM

Previous topic - Next topic

SaltAddict

Is there a way to make the helper stay relative to a position while it moves?

For example, my character creates a helper (that is binded to root) that creates a diagonal projectile helper, while my character is moving backwards. Is it possible to make the diagonal helper move backwards with the character, but at the same time, keep flying diagonally?

altoiddealer

So wait, does it change direction when the character walks backwards?

Or are you saying that it should continue flying forward... but the player's movement influences the X velocity?

I'm just not following your description here


Odb718

You could do it a couple ways.
One would actually be the animation. Where it's always bound to 0,0. But in the animation it flies up & to the right. It'll look choppy.

I think the next way would be to do some sort of posadd. Maybe 2 helpers nested in each other but the root might be enough.

You could try using a bindtoroot or parent with math. Like figure out the distance vs time.
[State 0, BindToRoot]
type = BindToRoot
trigger1 = 1
time = 1
pos = Floor(time/7),Floor(time/7)

Something like that might work. I havent tested to see if that would run though.
vVv Gouken718 vVv SabreTooth718 vVv


SaltAddict

Quote from: altoiddealer on August 16, 2016, 10:33:07 PM
So wait, does it change direction when the character walks backwards?

Or are you saying that it should continue flying forward... but the player's movement influences the X velocity?

I'm just not following your description here

I mean it should continue flying diagonally, but when the player moves backwards, it should move backwards WHILE flying diagonally



Quote from: Odb718 on August 16, 2016, 11:47:56 PM
You could do it a couple ways.
One would actually be the animation. Where it's always bound to 0,0. But in the animation it flies up & to the right. It'll look choppy.

I think the next way would be to do some sort of posadd. Maybe 2 helpers nested in each other but the root might be enough.

You could try using a bindtoroot or parent with math. Like figure out the distance vs time.
[State 0, BindToRoot]
type = BindToRoot
trigger1 = 1
time = 1
pos = Floor(time/7),Floor(time/7)

Something like that might work. I havent tested to see if that would run though.

The floor thing doesn't work, it just causes the projectile to move very slowly


Felkazz

Do you mean something like this?


If yes, you can try something like this:

[State 7000, Pos]
Type = PosSet
Trigger1 = 1
X = Root,Pos X + INITIAL_POS_X + (Time * VEL_X)
Y = Root,Pos Y - INITIAL_POS_Y - (Time * VEL_Y)

Just replace INITIAL_POS_X and INITIAL_POX_Y with the helper's initial position relative to the char and replace VEL_X and VEL_Y with the desired velocity

SaltAddict

Quote from: Thunderbert on August 17, 2016, 02:54:34 PM
Do you mean something like this?


If yes, you can try something like this:

[State 7000, Pos]
Type = PosSet
Trigger1 = 1
X = Root,Pos X + INITIAL_POS_X + (Time * VEL_X)
Y = Root,Pos Y - INITIAL_POS_Y - (Time * VEL_Y)

Just replace INITIAL_POS_X and INITIAL_POX_Y with the helper's initial position relative to the char and replace VEL_X and VEL_Y with the desired velocity

Exactly like that. But that code doesn't work. I tried:

[State 7000, Pos]
Type = PosSet
Trigger1 = 1
X = Parent,Pos X + 25 + (Time * 10)
Y = Parent,Pos Y - 25 - (Time * 10)


And it doesn't do anything. So then I tried:

[State 7000, Pos]
Type = PosSet
Trigger1 = 1
X = Root,Pos X + 25 + (Time * 10)
Y = Root,Pos Y - 25 - (Time * 10)


And it still doesn't do anything.

Felkazz

You need to remove the VelSet you have already done and let only the PosSet do the work.

Jesuszilla


SaltAddict

Quote from: Thunderbert on August 17, 2016, 07:45:35 PM
You need to remove the VelSet you have already done and let only the PosSet do the work.

Nope, still doesn't work. The projectile moves, but the bind doesn't work


Quote from: Jesuszilla on August 17, 2016, 10:18:29 PM
Look in the code library for my dizzy star code.

Can't find it. Searched all pages of the code library and the code archive thread but I can't find it :(

Felkazz

Can you post your code? Maybe there is something interfering with it

JustNoPoint


SaltAddict

Quote from: Just No Point on August 18, 2016, 08:18:01 PM
Quote from: FastFlash on August 18, 2016, 04:52:10 PM
Quote from: Jesuszilla on August 17, 2016, 10:18:29 PM
Look in the code library for my dizzy star code.

Can't find it. Searched all pages of the code library and the code archive thread but I can't find it :(
http://mugenguild.com/forum/topics/how-create-dizzy-stars-effect-165274.0.html

Oh, thanks. Can't believe I missed that.

Quote from: Thunderbert on August 18, 2016, 08:04:59 PM
Can you post your code? Maybe there is something interfering with it

Here it is, sorry, it's a bit messy. 100019 is the actual projectile. 100017 creates the projectile.

Spoiler (click to show)


[Statedef 100017]        ;Change the value to fit your needs
type = A
movetype = A
physics = N
ctrl = 0
velset = 0,0
sprpriority = 2
anim =100017
juggle = 2

[State 420, Helper]         ;This summons helper
type = Helper
trigger1 = 1
persistent = 0     ;It summons when the state is at the 11th tick. Change as needed.
helpertype = normal         ;Normal, so not player XD
name = "Kamehameha Blast" ;Give it a name, it's a good thing.
ID = 100013               ;The indentification number of the helper
stateno = 100019         ;The helper's stateno. If you change it in the helper's state, change it here too.
pos = 25, -25              ;The position where the helper appears
postype = p1                ;It defines from where it counts the distance.
facing = 1                  ;1 is foward, -1 is backward. We want it foward.
keyctrl = 0                 ;Keep this at 0.
ownpal = 1                  ;This means that the parent's PalFX's won't affect the helper.

[State 4000, BindToRoot]
type = BindToRoot ; This is to ensure the proper position for the helper.
trigger1 = 1
ignorehitpause = 1
pos = 15,-27

[State 212100, Reset]
type = assertspecial
trigger1 = 1
flag = noshadow

[State 1210, State]
type = changestate
triggerall = numhelper(100011) && numhelper(100012) && numhelper(100013)
trigger1 = Time <= 0 && helper(100011), var(1) + helper(100012), var(1) + helper(100013), var(1) >= 6
trigger2 = time <=0 && helper(100012), stateno = 100014 + helper(100013), stateno = 100015
value = 100014

[State 1210, State]
type = changestate
trigger1 = !numhelper(100013)
value = 100014


[State 1210, Destroy]
type = DestroySelf
trigger1 = BackEdgeBodyDist <= -100
trigger2 = FrontEdgeBodyDist <= -100

[Statedef 100018]        ;Change the value to fit your needs
type = A
movetype = A
physics = N
ctrl = 0
velset = 0,0
sprpriority = 1
anim =100018
juggle = 2


[State 1000, 7]
type = playerpush
trigger1 = 1
value = 0


[State 212100, Reset]
type = assertspecial
trigger1 = 1
flag = noshadow

[State 1210, State]
type = changestate
trigger1 = !numhelper(100013)
trigger2 = !numhelper(100011) 
value = 100015
ignorehitpause = 1

[Statedef 100019]        ;Change the value to fit your needs
type = A
movetype = A
physics = N
ctrl = 0
sprpriority = 3
anim =100019
juggle = 2

[State 7000, Pos]
Type = PosSet
Trigger1 = 1
X = Root,Pos X + 25 + (Time * 10)
Y = Root,Pos Y - 25 - (Time * 10)

[State 420, Helper]         ;This summons helper
type = Helper
trigger1 = 1
persistent = 1     ;It summons when the state is at the 11th tick. Change as needed.
helpertype = normal         ;Normal, so not player XD
name = "Kamehameha Trail" ;Give it a name, it's a good thing.
ID = 100012               ;The indentification number of the helper
stateno = 100018          ;The helper's stateno. If you change it in the helper's state, change it here too.
pos = 0, 0              ;The position where the helper appears
postype = p1                ;It defines from where it counts the distance.
facing = 1                  ;1 is foward, -1 is backward. We want it foward.
keyctrl = 0                 ;Keep this at 0.
ownpal = 1                  ;This means that the parent's PalFX's won't affect the helper.
ignorehitpause = 0



[State 1210, NotHitBy]
type = NotHitBy
trigger1 = 1
value = SCA, NA, SA, HA, NT, ST, HT
time = 1

[State 1210, HitBy]
type = HitBy
trigger1 = 1
value = SCA, NP, SP, HP
time = 1

[State 1210, HitOverride]
type = HitOverride
triggerall = numhelper(100011) && numhelper(100012) && numhelper(100013)
trigger1 = var(1) >= 6
time = -1
attr = SCA, NP, SP, HP
slot = 1
stateno = 8101
ignorehitpause = 1

[State 1210, HitOverride]
type = HitOverride
triggerall = numhelper(100011) && numhelper(100012) && numhelper(100013)
trigger1 =  var(1) < 6
time = -1
attr = SCA, NP, SP, HP
slot = 0
stateno = 10009
ignorehitpause = 1

[State 1210, VarAdd]   ; Check # of hits, successful or guarded
type = VarAdd
trigger1 = MoveContact
ignorehitpause = 1
v = 1
value = 1

[State 212100, Reset]
type = MoveHitReset
trigger1 = MoveContact
ignorehitpause = 1

[State 212100, Reset]
type = assertspecial
trigger1 = 1
flag = noshadow



[State 1210, 3]
type = HitDef
triggerall = numhelper(100011) && numhelper(100012) && numhelper(100013)
trigger1 = 1 && helper(100011), var(1) + helper(100012), var(1) + helper(100013), var(1) < 6
id = 1000
p1sprpriority = 3
attr = S, SP
damage = 25, 5
animtype = Hard
priority = 7,Hit
hitflag = MAF
guardflag = MA
hitsound = S1,1
guardsound = S1,0
pausetime = 8,8
sparkno = -1
guard.sparkno = -1
sparkxy = 0, 0
ground.type = High
ground.slidetime = 15
ground.hittime  = 20
ground.velocity = -6,-2
air.hittime = 20
air.type = Low
air.velocity = -6,0
air.fall = 1
fall = 1
fall.recover = 0
envshake.time = 17
envshake.freq = 30
envshake.ampl = -12


[State 212100, Reset]
type = assertspecial
trigger1 = 1
flag = noshadow

[State 1210, State]
type = destroySelf
trigger1 = !numhelper(100011)  ; # of hit/guard hits successful
ignorehitpause = 1

[State 1210, State]
type = changestate
triggerall = numhelper(100011) && numhelper(100012) && numhelper(100013)
trigger1 = Time <= 0 && helper(100011), var(1) + helper(100012), var(1) + helper(100013), var(1) >= 6
value = 100016

[State 1210, Destroy]
type = DestroySelf
trigger1 = BackEdgeBodyDist <= -100
trigger2 = FrontEdgeBodyDist <= -100




Cyanide

So, i see nothing wrong with that code. It is basically a direct copy from Thunderberts. Therefore something else is going wrong. Lets confirm that the code itself is doing well... anything.

If the projectile is moving the posset MUST be working. Nevertheless.

Alter it so it binds in specific spots and test each time. Change it to 25,-25. Confirm it shows up. Change it to 50,-50, confirm it goes where you expect. If that is working then the posset isn't at fault.

Alternatively

[State BindToRoot]
type = bindtoroot
trigger1 = 1
pos = 25+(time*10), -25-(time*10)

Should do something similar. This also takes facing so you could potentially make the helper always face the same way as the root although that might look a tad weird if it's a genuine beam.


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.

SaltAddict

Quote from: Cyanide on August 19, 2016, 12:04:56 PM
So, i see nothing wrong with that code. It is basically a direct copy from Thunderberts. Therefore something else is going wrong. Lets confirm that the code itself is doing well... anything.

If the projectile is moving the posset MUST be working. Nevertheless.

Alter it so it binds in specific spots and test each time. Change it to 25,-25. Confirm it shows up. Change it to 50,-50, confirm it goes where you expect. If that is working then the posset isn't at fault.

Alternatively

[State BindToRoot]
type = bindtoroot
trigger1 = 1
pos = 25+(time*10), -25-(time*10)

Should do something similar. This also takes facing so you could potentially make the helper always face the same way as the root although that might look a tad weird if it's a genuine beam.

What I meant was, the posset DOES work, but the helper doesn't follow the player. It's the same thing with your code, the helper shows up in the correct position, with correct speed, but it doesn't follow the root or the parent.

Felkazz

That is really strange... It should work... If you want, upload your char and PM it to me so I can have a better look and see what is the problem with your helper ^^

Cyanide

How can it have correct speed and not follow the parent. You don't actually SET speed in 100019. There is no velset. How is the projectile moving if the bindtoroot isn't working AND there is no velset?

You have another state 100019 is my current opinion.


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.

SaltAddict

Quote from: Cyanide on August 20, 2016, 03:02:03 AM
How can it have correct speed and not follow the parent. You don't actually SET speed in 100019. There is no velset. How is the projectile moving if the bindtoroot isn't working AND there is no velset?

You have another state 100019 is my current opinion.

Nope, just checked, even used the "find" tool to make sure. There's only one state 100019.

Cyanide

So we return to the previous question. How is the projectile moving if there is no velset in that state? You don't have a velset. If the bind is NOT working the projectile should not move at all. If the projectile is moving then the bind is working somehow.

Do a simple helper creation in light punch. Make it do nothing other than the code we gave you. If that works it's something wrong with your state.


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.

Felkazz

#18
I looked at the char and found the problem ^^
The thing is, the helper that causes damage IS moving according to the char, but the TRAIL is not! The trail is static, it doesn't move at all, so, we need to make it follow the char!
As the "head" spawns multiple trails, I made the trail "follow" the head with the reverse speed of the "head". So, put this on state 100018 and it should work:

[State 100018, BindToParent]
Type = BindToParent
Trigger1 = 1
Pos = -Time * 10, Time * 10

Odb718

Quote from: Odb718 on August 16, 2016, 11:47:56 PMYou could try using a bindtoroot or parent with math. Like figure out the distance vs time.
[State 0, BindToRoot]
type = BindToRoot
trigger1 = 1
time = 1
pos = Floor(time/7),Floor(time/7)

Something like that might work. I havent tested to see if that would run though.
Odb718 ftw lol.
But seriously, quoting because of the odd need for Floor(). When ever I do math like this, unless I know it's something like Velocity that I know that can go into fractions, I always use Floor() just out of habit. Root probably shouldnt be used for the "tail" if it's supposed to focus on the actions of a helper.
And do Floor(time * parent,vel x *-1) or something similar if you want the true reverse of the head.
vVv Gouken718 vVv SabreTooth718 vVv