YesNoOk
avatar

An issue binding an opponent in the middle of the screen (Read 3499 times)

Started by Sir Ghostler, November 26, 2016, 06:07:00 pm
Share this topic:
An issue binding an opponent in the middle of the screen
#1  November 26, 2016, 06:07:00 pm
  • ***
  • Working on MUGEN characters, 24/7.
    • Australia
So I'm coding a divekick Super which is supposed to bind the opponent in the middle of the screen on the x axis. For the most part, the Target Bind I'm using works fine when the opponent is on the ground standing, however there are positioning issues I have been encountering otherwise.

Currently, connecting the divekick too close to a position of 0 on the y axis and during an aerial hitstate will cause the victim to be sent to either side of the screen instead. Here's the code:

Spoiler, click to toggle visibilty

I can post the rest of the code for the Super/Custom State if need be. Any and all help is appreciated.
Last Edit: November 29, 2016, 06:58:15 pm by ゴーストキラー
Re: An issue binding an opponent in the middle of the screen
#2  November 26, 2016, 10:40:42 pm
  • ******
    • www.justnopoint.com/
Screenpos can change depending on where the attacker jumps around if the camera is able to follow the attacker. May want to just try pos or lock the camera so it doesn't move?

Edit: bind with screenpos then on the next tick use pos instead?
Last Edit: November 26, 2016, 10:46:52 pm by Just No Point
Re: An issue binding an opponent in the middle of the screen
#3  November 27, 2016, 05:47:33 am
  • ***
  • Working on MUGEN characters, 24/7.
    • Australia
Hmmm, well I wasn't using a ScreenBound in the first part of the super (State 3400). I coded the move so that the moment the first part connects, the player and opponent would both be sent to states (3401 and 3425 respectively) which then lock the camera for both on the same tick. I just tried locking it in the first part too and it doesn't fix the issue.

Just tried using binding with pos after screenpos like you suggested, it didn't seem to work. Maybe I messed up, not sure.

I'll just post the code that I have so far anyway actually:

Spoiler, click to toggle visibilty
Re: An issue binding an opponent in the middle of the screen
#4  November 27, 2016, 06:10:21 am
  • ******
    • www.justnopoint.com/
I've never tried coding this so I apologize for just throwing things against the wall and seeing what sticks but if no one has a better solution I wonder if this may work:

Set the width of P2 to be as wide as the screen and set player push to 0. Using this with screen bound you may be able to prevent him from moving left and right. If that works you might even be able to go as far as making P2 invisible and setting a helper that uses p2's animations and has width and height set to be the same as the screen. With screenbound they may make it look like P2 is staying dead center.

I won't be able to actually test alternatives till Wednesday and I'm sure there is an easier solution so I'd wait. But it may be a decent fallback idea to try.
Re: An issue binding an opponent in the middle of the screen
#5  November 27, 2016, 11:24:58 am
  • ***
  • Working on MUGEN characters, 24/7.
    • Australia
That's definitely an interesting approach. I'll give it a go in a bit and see how it works out.

And no need to apologize, man. I'm thankful you're taking time out of your day to help and offer suggestions either way. :)
Re: An issue binding an opponent in the middle of the screen
#6  November 27, 2016, 01:48:53 pm
  • *****
  • Shame on you!
    • USA
You could skip the targetstate !time && numtarget by using
Code:
[State 3400, Hit 1]
type = HitDef
triggerall = 1
trigger1 = !time
attr = S, HA
hitflag = MAF
id = 3400
getpower = 0
givepower = 0
sparkno = -1 + 0 * (var(20) := 8000)
guard.sparkno = -1 + 0 * (var(21) := 8500)
sparkxy = 0 * (var(23) := 55), 0 * (var(24) := -20)
hitsound = S200, 320
guardsound = S120, 0
p1stateno = 3410
p2stateno = 3425  ;Not sure what youre using to not use this <<<<
fall.recover = 0
fall = 1

Use this to set the pos in P2
Code:
[State 3425, Set Position]
type = PosSet
trigger1 = time = 1
x = ifelse((facing = 1), 145 - ceil(screenpos x), -40 - ceil(screenpos x))
y = 180 - ceil(screenpos y)

[State 3425, Set Position]
type = PosSet
trigger1 = time = 2
x = 0
y = -20
Or what ever exact values you need. Also ScreenPos X will probably vary because of different stages I _believe_. Dont quote me on that.  I dont think the facing will matter for that fact. No matter which way P2 is looking ScreenPos X is the same.

Because you're in the custom state you're not limited to only controlling P2 through P1's states. (well technically you ARE...)
If you need P2 to go somewhere, put them in their statedefs.
vVv Gouken718 vVv
Re: An issue binding an opponent in the middle of the screen
#7  November 27, 2016, 04:40:21 pm
  • ******
    • www.justnopoint.com/
Iirc screenpos only changes due to the camera but my use of it has been limited. I forget what the center would be 0,0? Anyway if I'm right then you may be able to use a constant posset = screenpos instead of using target bind.
Re: An issue binding an opponent in the middle of the screen
#8  November 27, 2016, 07:58:20 pm
  • ***
  • Working on MUGEN characters, 24/7.
    • Australia
I tried JNP's method of increasing the opponent's width, it just seemed to force them off screen.

Odb, I made the changes you suggested. I removed the TargetState and used p2stateno in the HitDef instead, and changed the TargetBinds to PosSets and placed them in the victim's custom state. I am still getting position issues with the move unfortunately.

I'm gonna rehaul the move a little bit. I'll try looking at some other characters who have similar binding moves as well.
Re: An issue binding an opponent in the middle of the screen
#9  November 28, 2016, 02:13:56 am
  • *****
  • Shame on you!
    • USA
Well describe what the problem(s) are.
You have the center for 1 tic, then you set it 20 pixels up. Are you supposed to lock the character to the second point? You'd want to constantly set the position over and over so it doesn't move. Can you possibly use something like bandicam to make a small vid and youtube it?

 Try
[State 3425, Set Position]
type = PosSet
trigger1=animelemtime(1)>1 ;this
x = 0
y = -20

^^^This also sets P2 relative to the floor and not the screen.
Here is the code to lock the Y position of a Player by applying a constant Velocity.

[State 1111, 0]
type = VelSet
trigger1 = 1
y = (GameHeight/2)+60-ScreenPos Y

Replace the "60" to suit your needs.

"GameHeight/2" makes the position relative to the center of the screen.  If you want it relative to the bottom, just use (GameHeight - XXX)-ScreenPos Y

So you'd probably want

[State 3425, Set Position]
type = VelSet
trigger1=animelemtime(1)>1
x = 0
y = (GameHeight - 20)-ScreenPos Y
vVv Gouken718 vVv
Re: An issue binding an opponent in the middle of the screen
#10  November 28, 2016, 04:27:18 am
  • ****
  • Robotics Engineer
    • USA
    • altoiddealer@gmail.com
Velset or Posset will do basically the same thing, except Velset will prevent glitches on stages where the floor bobs up and down (there's at least a few of them)

Re: An issue binding an opponent in the middle of the screen
#11  November 28, 2016, 06:18:30 am
  • avatar
  • ***
  • Original characters are my forte.
    • http://network.mugenguild.com/bane84/
Based on what I've read, I'm assuming that you might want to try something like this?
Place P2 into a custom state.  For every tick that you want the target to be bound in the center of the screen:
Code:
[State X, CenterBindX]
type = PosAdd
trigger1 = <Whatever Trigger>
X = -ScreenPos X+floor(GameWidth*0.5)

The idea is that the target's position is first set to the left edge of the screen, then we add half of the game's width.  As the screen width changes, the center of the screen also changes.

There may be another trigger you could use to get the total width of the screen, so it will require some experimenting.  I'm not sure how zoom will affect this either since I haven't really experimented with it.
Re: An issue binding an opponent in the middle of the screen
#12  November 28, 2016, 04:39:26 pm
  • ***
  • Working on MUGEN characters, 24/7.
    • Australia
Well describe what the problem(s) are. You have the center for 1 tic, then you set it 20 pixels up. Are you supposed to lock the character to the second point? You'd want to constantly set the position over and over so it doesn't move. Can you possibly use something like bandicam to make a small vid and youtube it?

The problems I meant were that the opponent still gets sent to the edge of the screen instead of the center.

So I've used Altoid's sctrl to lock the Y vel, and it works fine, no issues which is good. I've then used Bane's sctrl to lock the X axis which looks to have fixed the problems mentioned in the main post, but only seems to do so when facing to the left.

I recorded a video showing what's currently happening:
Spoiler, click to toggle visibilty

Here is the most recent code for the victim's custom state:
Spoiler, click to toggle visibilty
Re: An issue binding an opponent in the middle of the screen
#13  November 28, 2016, 05:35:18 pm
  • ****
  • Robotics Engineer
    • USA
    • altoiddealer@gmail.com
Try this:

[State 3425, Set X Position]
type = PosSet
trigger1 = animelemtime(1) > 1
x = 0
persistent = 0

[State 3425, Set Y Position]
type = PosAdd
trigger1 = animelemtime(1) > 1
y = Floor((GameHeight/2)-ScreenPos Y)
persistent = 0

[State 3425, Lock Y Position]
type = VelSet
trigger1 = animelemtime(1) > 1
y = (GameHeight/2)-ScreenPos Y


You can try consolidating the first 2 ctrls to just one PosSet, but for some reason it didn't work right when I tried it...

Re: An issue binding an opponent in the middle of the screen
#14  November 29, 2016, 06:57:34 pm
  • ***
  • Working on MUGEN characters, 24/7.
    • Australia
That seems to have fixed it! Finally, I can make some real progression with this super, lol. I'll post back if I come by any issues with it later on. Everyone, thank you all so much for your help! I really, really do appreciate it! :) Topic solved.