Snowboarding game - Altering hitbox sizes on the fly.

Hopefully this will be my last question on this subject. My snowboard game works by scrolling events up the screen, then teleporting them down to a new designated location, further down the map, scrolling them back up and repeating. Thanks to @Slaughty the system works, but because my map is not randomly generated I had to create 42 variables to accomplish it. This is a set piece, so I don't care!

Unlike the front facing obstacles, the vertical faces on the walls don't need to do anything but block the player's movement. The issue is that if I have a string of vertical events, I would have to create dozens of them.

I figured I would try creating a system where I just have one event for each wall & then adjust the hit box size each time the event relocates further down on the map. My hitboxes are done using Visustellar's Event and Movement Core.

The idea is, scroll the event up> teleport down > change hitbox size (repeat). I don't want to create a ton of variables to accomplish this. There's no room for randomization. Self switches aren't an option.

I've recorded a video to demonstrate if my request is unclear. Thanks in advance and sorry for being rubbish.
use event hitbox event size plugin 😀

and use variable and event pages if you set the event size as comment.
you can control it there (if size changes too, this is the best way to handle).
use event hitbox event size plugin 😀

and use variable and event pages if you set the event size as comment.
you can control it there (if size changes too, this is the best way to handle).

I don't want to create 21 more variables (one for each wall). It's getting crazy. Is there another way?
1 variable array, but looking back it can be a mess.

selfvariable/selfswitch (A~Z) might work, this could work, as each event
uses their own variable/switches to swap pages (or at random).
I am not sure if you want to change your workflow a bit, but for your Event Controller, you can replace your variable assignments using this for the script call portion of the conditional branch and then run your event commands inside it (play se, set move route for player to move back a few steps, etc.).

Spoiler
The event commands are simpler to use, yes. However, taking up so many variables to do a logic check is not efficient use of your event space and game variables.

(Untested, but I might be able to do more when I get a chance to get to the computer) - I am assuming you are pushing the player back when any event's position is equal to the player so you can add those event commands below where I put 'Comment':
JavaScript:
◇Wait : 1 frame
◇IF : Script : $gameMap.events().filter(e => e.event().name.includes('Obj')).some(event => $gamePlayer.pos(event.x, event.y))
  ◇Comment: Your event commands here
  ◇
: End
These commands will wait for 1 frame (for performance improvement) each run and filters out events that have 'Obj' in its name. It then checks if one of the events has the same position as the player. If so, it returns true and runs the event commands nested in the conditional branch.

(below not required):
Usually, I will add <object> or something else in the note field and reference that instead of the event's name for better searching/indexing because if you consider localization later on (should the game ever need to be localized to different languages, etc.), the naming of events will most likely be changed. Using the notes field issbetter practice.
1 variable array, but looking back it can be a mess.

selfvariable/selfswitch (A~Z) might work, this could work, as each event
uses their own variable/switches to swap pages (or at random).
How the hell do self variables work? As stated I have VisuStellar's events & movement core which handle them. But I don't get it at all!

I know there's plugin command, I know there's a variable condition, I get Map ID, Event ID and Variable ID. I just do not understand this process.

Forgive me for being slow, but I can't make head nor tail of this stuff.

I am not sure if you want to change your workflow a bit, but for your Event Controller, you can replace your variable assignments using this for the script call portion of the conditional branch and then run your event commands inside it.

That sounds crazy! I'm assuming it will let me yeet about 38 variables, so I'm very interested to dig in. I really just want to focus this thread on changing those hitbox sizes. The big question of the day is how to use "self variables". If anyone can explain them to me, I'll consider this case closed.
Unfortunately, since the VS stuff is obfuscated (and I don't use MZ or VS), there's not much to do besides use the available notes for hitboxes and script calls for self variables.

Edit: First Part of Post
Spoiler
I would use different pages and use different notes on each page and just switch to those pages to get different hitboxes. I don't see any viable script calls or plugin commands to do change the hitbox size via script so setting up several pages with the proper hitbox notes should be sufficient - just switch to the page.

If you are using the self-variable as a condition, be sure to preface the name of that specific variable you want to use with <Self>. So, let's say you are using Game Variable 10 and you want to name it Harold. In the Variables Database, you would name it <Self> Harold and in your event page's conditions, click on variable and assign that to the event (I will use event 5 for this example).

sv1.png


Now in order for that page for event 5 to run, the self variable value will need to be 5 or greater.

To set/get those values, you will need to use the script calls:
setSelfVariableValue(mapID, eventID, variableID, value)
JavaScript:
setSelfVariableValue($gameMap.mapId(), 5, 10, 5);
and
getSelfVariableValue(mapID, eventID, variableID)
JavaScript:
getSelfVariableValue($gameMap.mapId(), 5, 10);
If my memory serves me correctly with the MV Yanfly stuff, you should be able to set/get the self-variables of any map/event.
Here is more information to review when you get the chance:

Events and Movement Core (scroll down or search for "self variable").

I have a mockup of something similar (rocks falling, scrolling items, etc.) so I'll post that when I get the chance.

Edit: Follow-up Post
Spoiler
Video:


Here is a rough draft of moving events, player interaction, and a parallel event controlling everything. There is a lot of info here so I will use spoilers to make it easier to read.

Map: 17x23 - 1 Parallel Event, 13 Events with Move Function
Spoiler
snow1.png
Custom Move Route for all 13 Events that reference the function snowRoll():
Spoiler
snow2.png

Code:
 - All events are named Obj with their respective numbers
   and have the meta tag <evPass> in the Note field for easy
   reference/filter later on
 - All events are walking/stepping and have their priorities set to
    'Same As Character'
 - There is no need to make the trigger parallel because we are
    using the Autonomous Move Route
 - Autonomous Move Routes will activate when the player is near OR
    by using _moveRouteForcing.
Page 1 of Event 1 - Autorun:
Spoiler
snow3.png

Code:
 - Define variables for $gamePlayer, $dataMap.events, and a filter for all events
    with the meta (the Note field) 'evPass'.
 - Iterate with a loop through the filtered events to place them outside of the
    map boundaries (y + 3).
 - Force the autonomous movement to activate for all those events since the autonomous
    movement route only activates when the player is within range (I think about 20 tiles,
    horizontal and vertical)
Page 2 of Event 1 - Parallel:
Spoiler
snow4.png

Code:
 - 1 wait frame for performance but also maintain accuracy
 - Define Variables for $gamePlayer and find the exact event out of all the events
    with the note meta tag 'evPass'.
 - If the event's move speed is faster than 4.4, it has a 'collision' of 3 tiles (1 to the left,
    the event's center, and 1 to the right), otherwise, it can only 'collide' with the player
    on its own x coordinate when it matches.
 - Check if the player's real Y coordinate is no more than 1 tile away from the event
    and no less than the event's real Y coordinate - this is so the player can 'collide'
    with the event.
 - If there is an event that matches the above requirements, reference that
    event to game variable 1.
 - If game variable 1 is NOT 0/empty:
    - Set the movement route for the player (skip and wait).
    - Fix the direction of the player.
    - Run a script that allows the player to be pushed back at the same speed as
       the event that has 'collided'
    - If the event's speed is below 3.7, push the player back by 1 tile (green flame).
    - If the event's speed is above 4.4, push the player back by 3 tiles (purple flame).
    - If the event's speed is anything else (in between), push the player back
       by 2 tiles (blue flame).
    - Set the player's speed to 5 and jump forward 1 tile to put the player
       back into position.
    - Run a script that checks if the player's y is less than 0 (off-grid) - if so, run
       command 353 (Game Over).
    - Turn direction fix off and reset the speed to normal (4) for the player.
    - Set the game variable 1 to 0.
Code for the function snowRoll():
Spoiler
snow5.png

Code:
 - charSprite() is a custom function that returns the character sprite 
    of 'this'. It is the equivalent of:
    SceneManager._scene._spriteset._characterSprites.find(c => c._character === this);

 - Set the variable for $dataMap.events for the current event running the code.
 - If the event's current y is equal to the event's database/starting value of y
    plus 2 (off-grid):
    - Set the move speed to between 3.0 and 5.0.
    - If the move speed is less than 3.7, keep the scale of the event(x, y) to 1, 1 (normal)
       and set the color tone to be more green
    - If the move speed is greater than 4.4, scale up the event(x, y) to 2.2, 2 (twice as big
       with a bit more width) and set the color tone to be more purple (normal color is blue
       so it becomes purple with more red added)
    - If the move speed is anything in between, keep the scale and color tone normal (blue)
 - If the event's y is less than 0 (off-grid), relocate the event to any of the x coordinates
    between 2 and 14 and set the y coordinate to be 3 tiles off grid (y + 3).

- Allow the snowRoll() function to be used in the Game_Character interpreter
  (the term "this" in the Move Route).

- Modify the existing function moveStraight() under the Game_CharacterBase prototype:
    - create a variable that checks for true/false to make sure the character is an event and
       to see if that event has the meta tag 'evPass'
    - When checking for movement success, add the OR || operator to allow for all events
       with the 'evPass' to pass through anything but still collide with the player (notice the
       events are set to 'Same As Character')
    - Everything else in the function can remain the same to check and allow the
       character to move straight
This is a tricky one, i think theres potential use of region ID
I would use different pages and use different notes on each page and just switch to those pages to get different hitboxes.
WOW!! You're a gem!

I actually managed to achieve this in a completely different way. I finally figured out self variables on my own last night. I feel guilty now that I didn't close this thread, because you've clearly put a bunch of work in to this response. However, perhaps it's for the best because I am suffering from two more issues.

It also seems that you might have misunderstood the question a bit.
I'm trying to extend hitboxes vertically, not horizontally. The behaviour when he hits the horizontal face should be to bounce him back, the behaviour when he hits a vertical face should simply be to block his movement.

You've got all kinds of neat stuff going on in your version with speed variations and stuff. Those extras have really scrambled my brain though and are not things I need. As a n00b it takes me a while to comprehend everything.

Because you might not understand the problem fully, I'm very hesitant to proceed with your instructions.

I'll show you my method for Self Variables with hitbox alterations.

Your method is much more sophisticated.

1742117475789.png


None of this is done with a controller. Obviously each page has a different number on the self variable. Each time the event hits the top of the screen it switches the event page.

My current issue is as follows...

As mentioned, my current method features a top facing event (one that makes the player bounce backwards) and a trailing event (one that just represents the vertical walls). Currently, if I'm quick, I can run between the top facing event and the side facing event that trails it & because through is turned off for the trailing side event it cant move and breaks everything.

I can't quite tell if I'm interpreting your response correctly.

The one thing that you've done that has really piqued my interest is that you've offset the front collision. The term "collision" might be the route of some communication issues though. I shall try to disambiguate.

In one sense collision could mean the player reaction is triggered by touching the event's hitbox, let's call this a touch.
In another sense it could mean that his reaction is triggered by touching the actual event, let's call this a hit.
In another sense it could mean the player's X&Y overlap the Event's X&Y, let's call this an overlap.

In my method (using a front facing event and a trailing side facing event), the player bounces back when the front face overlaps with the player's coordinates. If he touches or hits a side face he simply cannot pass through it.

1742126864962.png


In your version, I can't tell if on downward impact the player's reaction is triggered by touching or hitting the event. If it is, that leads me to believe that the movement of the event will pause momentarily.

One big question is do your events pause at all on collision with the front?

If they do it's a problem. If they don't, it's a massive plus.

Second question is, does your character still bounce if he collides with the side of an obstacle? I can't really tell.

If he doesn't that's wicked. I only want the character to bounce if he collides with the top of an obstacle. If he collides with the side, it should just be an unpassable barrier.

The reason why I ask these questions is because If both of those questions are answered in the affirmative, I can combine all the functionality into just 21 events (line up from left to right) without the need for a secondary group of followers. That would be AWESOME!

p.s. VisuStellar's Movement Core allows for movement of events across the entire map, well outside the range of the player. Changing hitbox sizes is easy as anything, just comment <Hitbox Down: 5> or whatever.
I'm trying to extend hitboxes vertically, not horizontally. The behaviour when he hits the horizontal face should be to bounce him back, the behaviour when he hits a vertical face should simply be to block his movement.
This can be achieved more easily with the hitbox resize plugin.
In your version, I can't tell if on downward impact the player's reaction is triggered by touching or hitting the event. If it is, that leads me to believe that the movement of the event will pause momentarily.

One big question is do your events pause at all on collision with the front?

If they do it's a problem. If they don't, it's a massive plus.
There is no delay when the flame crashes into the player head-on. The player is pushed back a few tiles and automatically jumps forward. If you watch the video closely, the events continue to move forward regardless of the player walking into the event or is standing still and being pushed back.

In normal circumstances, the event would pause a bit when collided and then proceed to move - I changed the code to allow for the event to not be affected by that movement when tagged with the meta tag <evPass>.

This also means that all collision is set to "same as character" and through is set to off - the player will honor the collision to the event but the event will proceed as if it were through to everything else on the map. Pretty cool, huh?

Second question is, does your character still bounce if he collides with the side of an obstacle? I can't really tell.
I was able to set up a similar event hitbox resizer plugin by Orange (Hudell) and when I collide in the front with the resizer applied to the flames, the player is moved back. If I set the hitbox size to be 3 tiles in height, I cannot move pass the flames in those 3 tiles (y + 3).

This means that if I am making walls out of events or barriers that move, I can do hitbox event size 10 and it will take up 10 tiles (x or y depending on what you want - in this case, you want y).

In any case, this is more of something that I am already working on and just put together quickly to demonstrate possibilities so it is more of a generalization of what we are doing in common rather than a replication of your exact response (creative process leads us everywhere and anywhere at any time - I started off with just a simple collision check and ended up experimenting instead lol).

You are always welcome to modify and change the code for your specific needs and take what works for you (which was why I thoroughly commented each script call/command/code to give you an idea of the workflow).

Thanks! Hope this works out for you.
If you watch the video closely
OH yeah, well done Lomaxient! Give yourself a raise! Read through 8 pages of response and COMPLETLY MISS THE VIDEO LINK staring me in the face!!! I feel like such a fool sometimes. I'm gonna print myself a T-Shirt with the word IDIOT on it and walk into town ringing a bell.

.

Now that I fully understand what your system is doing, I don't think it's gonna work. The main thing being that my system region locks the player's movement to the X axis. The thing is Slaughty has just suggested a totally different avenue from the one that I was pursuing & having slept on it I think I've been barking up the wrong tree this whole time. For now I'm gonna stick a pin in this whole endeavour and see what's down that road.

Thanks for taking so much time to respond. It's all worth it because, I'm learning stuff.
I'm gonna print myself a T-Shirt with the word IDIOT on it and walk into town ringing a bell.
Record a video, I wanna see.
Record a video, I wanna see.
I'll do it as soon as I've finished programming my game haha!
1742206653832.png
Now that I fully understand what your system is doing, I don't think it's gonna work. The main thing being that my system region locks the player's movement to the X axis.
Maybe I am misunderstanding then since in your video, you demonstrate being able to walk up and down. To remove that, you can do:
JavaScript:
[38, 40, 104, 98].forEach(id => delete Input.keyMapper[id]);
Your up key is 38 and numPad 8 is 104, and your down key is 40 and numPad 2 is 98. To restore those keys, do:
JavaScript:
[38, 40, 104, 98].forEach((id, index) => Input.keyMapper[id] = ['up', 'down'][index % 2]);
Now the player cannot move up or down. You can still move them with a move route or script call - they just cannot use the input until it is restored.

Or, do an autorun and only allow inputs left and right instead. You can make them move down automatically and then use left and right to move them diagonally.

Whatver you need, if there is a code base or a way to make it with js, it can be done.
 
Locking the player to the x-axis (or give the perception of it) can also be done with parallax movement or forcing the player to move continuously.

Also, no worries on the solution. Helping someone also teaches the one helping so any solution or help offered is simply another path to succeed, regardless if it met/exceeded/failed to meet expectations.

I learned a bit more about the canPass and movement success and was able to test my theory on making an event not stop when colliding with the player, but also can go through terrain and other events. Now I can make things pass/not pass whenever I need. Haha.
Maybe I am misunderstanding then since in your video, you demonstrate being able to walk up and down. To remove that, you can do:
Dude, you're so cool! The thing is, thanks to Slaughty, none of this matters anymore. I was pursuing the wrong avenue from the get go. Basically everything I've spent a week trying to accomplish has been knocked out of the park in a few hours. I'm in a shockingly good mood right now. The initial question on this thread has been resolved & then some, so I'm going to ask the mods to close it.

I'm learning mountains. I really can't thank you enough.

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/snowboarding-game-altering-hitbox-sizes-on-the-fly.176255/