Це відео не доступне.
Перепрошуємо.

How passable (one-way) platforms work in game development!

Поділитися
Вставка
  • Опубліковано 14 лип 2021
  • #shorts #gamedev
    One-way platforms are very common in platformer games, so in this video I go through how I implemented them in my game.
    This game is made with LOVE, feel free to check out my full tutorial:
    • [2021 Update!] Make Ga...

КОМЕНТАРІ • 747

  • @ghb323
    @ghb323 Рік тому +6313

    another way: check if y speed is upwards or downwards

    • @StickThisUpYourAnus
      @StickThisUpYourAnus Рік тому +4

      Wouldn't that cause clipping when the player jumps from underneath but falls back down mid transition?

    • @JamesMurphyInvest
      @JamesMurphyInvest Рік тому +349

      Couldnt the player still be under the platform whilst y speed is up? Therefore still colliding with the bottom of the collider?

    • @ghb323
      @ghb323 Рік тому +194

      @@StickThisUpYourAnus have the hitbox of your character’s feet to the platform be ~1px tall and the platform’s hitbox also 1px tall.

    • @guilhermehenrique-zj5tt
      @guilhermehenrique-zj5tt Рік тому +14

      i did like that.

    • @WellDressedMuffin
      @WellDressedMuffin Рік тому +469

      I think this solution is better. Instead of constant, repeated checks on every platform you only do a check when you need to. Event driven logic is much more performant.

  • @AxidoDE
    @AxidoDE 7 місяців тому +2840

    This video is brought to you by "Solving a computational problem by throwing more processing power at it".

    • @tomasgoes
      @tomasgoes 7 місяців тому +280

      Optimisation? What's that?

    • @Betterthenyou375
      @Betterthenyou375 7 місяців тому +308

      I’d say he’s working at the same level as some AAA dev’s. Saying fuck all to optimization.

    • @Pluto-ek3mh
      @Pluto-ek3mh 7 місяців тому +90

      What would be the optimal way of going about this?

    • @baronbacku9984
      @baronbacku9984 7 місяців тому +202

      ​@@Pluto-ek3mh wouldn't running the check whenever a collision would occur suffice?

    • @Pluto-ek3mh
      @Pluto-ek3mh 7 місяців тому +40

      @@baronbacku9984 That’s what I’m thinking, but this comment and its replies beg to differ.

  • @Stevejustt
    @Stevejustt 8 місяців тому +1526

    You can avoid all the constant checks by checking the collision normal when colliding. The normal will tell you which direction your hitting the platform from. Can just ignore if hitting from bottom 🤟

    • @dailyfunnytv358
      @dailyfunnytv358 8 місяців тому +81

      it's harder to do when you just use some guy's template on top of an engine you don't even understand 😂

    • @notnullnotvoid
      @notnullnotvoid 7 місяців тому +18

      No, that would be slower. Not that it matters, either way will be plenty fast enough, but installing a collision handler that runs for every collision event and check whether it's a player x platform collision is almost certainly more work (and importantly, less consistent/predictable amount of work per frame) than just iterating all the platforms every tick. That said, you probably want the collision handler anyway be able to conditionally ignore specific collisions instead of disabling the collider entirely.

    • @nintySW
      @nintySW 7 місяців тому +102

      @@notnullnotvoidIs this a joke? No way a collision handler (that Already has to run mind you, you're just hooking onto it.) is slower than running a check for every platform every tick, even with optimisation for only doing the closest few.

    • @notnullnotvoid
      @notnullnotvoid 7 місяців тому +18

      @@nintySW Yes way, it sure is slower. An extra (more complex) check on *every* ongoing collision every frame, vs. a simpler check per platform per frame and then the disabled hitboxes presumably don't even even enter broadphase at all let alone enter narrow phase and have their contact patch calculated? None of this matters, mind you, but yes, the contact listener approach will be slower. You learn these kinds of things in the process of shipping a physics-based game with a perf-sensitive sim step.

    • @theoverseer393
      @theoverseer393 7 місяців тому +1

      Have it detect the player by proximity

  • @the-rudolph
    @the-rudolph 3 роки тому +882

    Nice video! Unsolicited fun fact to boost the _algorithm_: In the original Super Mario Bros, the game checks if Mario is landing on an enemy (good) or being landed on (bad) just by checking Mario's vertical velocity component. Thus, you can squash a goomba from below if it lands on Mario while he is falling slower than it.

    • @Challacade
      @Challacade  3 роки тому +152

      I never knew that, they certainly got creative with their collision logic!

    • @michaeldiaz4285
      @michaeldiaz4285 Рік тому +5

      Thanks for the explanation !

    • @goldfishgallant1432
      @goldfishgallant1432 Рік тому +9

      Does that make sense? If a Goomba is walking then Mario's velocity is certainly greater when he lands on it. Wouldn't the Goomba need to be falling slower than Mario in order to squish it from below? Which should also be an impossible situation because if the Goomba is above and falling slower than Mario, Mario should never be able to collide with the Goomba.

    • @the-rudolph
      @the-rudolph Рік тому +34

      ​@@goldfishgallant1432 Just Mario's vertical velocity was checked, not the difference between the two characters!

    • @goldfishgallant1432
      @goldfishgallant1432 Рік тому +18

      @@the-rudolph So Mario just needs to have a vertical and falling velocity to kill the goomba?

  • @snesmocha
    @snesmocha 8 місяців тому +2174

    Insane amount of checks per minute… just get the normal of the object or set the normal to a directional vector

    • @makotomiyamoto5249
      @makotomiyamoto5249 7 місяців тому +34

      Could you explain?

    • @DARK_AMBIGUOUS
      @DARK_AMBIGUOUS 7 місяців тому +69

      If your saying to add a single square that only has a collision one one side, that works but it's a bad idea because the second the middle of your character goes threw it, it will teleport you forward till your fully out of it, or fully on the other side, I used to use this to make 1 way passages and stuff in my games but I stopped using this method

    • @Goteryup
      @Goteryup 7 місяців тому +32

      Games and even programs in general use an insane amount of checks per minute, I don't have much coding experience but I don't see why it's an issue to have more checks. From what I understand having checks is good but let me know if that's not the case

    • @KatherynneF
      @KatherynneF 7 місяців тому +12

      @@DARK_AMBIGUOUSjust make the one sided collision only apply to a specific collision box and have an additional thin collision box at your feet for ground detection

    • @cheggf
      @cheggf 7 місяців тому +88

      ​@@Goteryup More checks gives performance losses. A few platforms on their own wouldn't do much to the optimization, but it would add up with other things being coded in similar ways.

  • @omegaSomeone
    @omegaSomeone 7 місяців тому +29

    What I did on my one-way platforms was make two hitboxes: one for the bottom and one for the top (in the case of your grated platform, it would be the 2 highest pixels). The bottom hitbox lets anything pass through it, and is just there as a sensor: the higher hitbox would have no collision with anything touching the lower one, but would with anything not touching it.

    • @FerousFolly
      @FerousFolly 7 місяців тому +14

      pretty clean implementation, actually, very few checks needed. and dropthrough could be implemented by just shifting the player's collision box down by 3 pixels when pressing down on a platform, easily hidden with a brief and simple dropping animation

    • @theonewholearns2711
      @theonewholearns2711 6 місяців тому +4

      In other words, jumping at one-way platforms from the side risks hitting the side? Not a dev btw.

    • @FerousFolly
      @FerousFolly 6 місяців тому +3

      @@theonewholearns2711 nah you'd extend the lower hitbox out a bit at the sides to avoid that unless you want to have ledge hanging on them, in which case you'd have another hitbox at the edges and a ledge grabbing hitbox the top half of your character to acrivate the ledge hang state.

  • @CallMeCasper_
    @CallMeCasper_ Рік тому +134

    In Unity you can add a platform effector 2d and it makes it a one way platform automatically, just make sure to check "used by effector" on the collider you are wanting to change.

    • @autoimmunedefficiencysyndrome
      @autoimmunedefficiencysyndrome 7 місяців тому +7

      Unity 😂

    • @gamezboi_
      @gamezboi_ 7 місяців тому +3

      @@autoimmunedefficiencysyndrome wts wrong w/ unity

    • @Fishlady143
      @Fishlady143 7 місяців тому +13

      @@gamezboi_nothing, other engine devs just act like unity is trash

  • @thneitor
    @thneitor 7 місяців тому +35

    A trigger collider below the actual collider: I'm about to end this man's whole career

    • @DEVdreamweaver
      @DEVdreamweaver 5 місяців тому +1

      what about if you're coming from the side?

    • @thneitor
      @thneitor 5 місяців тому

      @@DEVdreamweaver You don't.

  • @zebede38
    @zebede38 7 місяців тому +19

    You could also have a check on collision to see if the player is below the position of the platform, and ignore it if it is

    • @Artholos
      @Artholos 7 місяців тому +5

      Nope. That would be simpler, easier, and scalable. Gotta do it the Threadripper way.

  • @kaboomsihal1164
    @kaboomsihal1164 Рік тому +424

    In godot I just check "one way collision" lol

    • @bubi1909
      @bubi1909 11 місяців тому +38

      Works in unity too with effector

    • @scrunky8683
      @scrunky8683 11 місяців тому +7

      any tutorials for that

    • @kaboomsihal1164
      @kaboomsihal1164 11 місяців тому

      @@scrunky8683 dude it's one checkbox. I don't make tutorials but there's about a dozen on youtube I can think of. It's also in the documentation. Or you just look at some of the sample projects with platforms. You really just need to spend 5 minutes looking for it.

    • @tPlayerioT
      @tPlayerioT 9 місяців тому +16

      of course, Godot has anything you may think of

    • @mouinhizem1428
      @mouinhizem1428 9 місяців тому +4

      go dot for kids
      Lmao

  • @mudsp1ash
    @mudsp1ash 7 місяців тому +6

    Unity has a component called Platform Effector2d that you can attach to your colliders. It ignores collisions from specific directions if you enable the one-way option.

  • @austindrexler2092
    @austindrexler2092 2 місяці тому +3

    This works fine if it’s just a single player and simple npcs. However this falls apart if you have add multiplayer or any traversal ai behavior. Also the colliders will spend every frame checking the player’s y position. I’d probably tie the collider flag (i.e. the character’s collision layer) to the entity that is jumping based on it’s movement vector. If a player or entity is moving in the positive y direction, it should not collide with platform. On the way down if it moves in the negative y or is at 0 delta it should check if its collider overlaps the platform. If not then switch the collision flag back. The neat thing with this is you can also make the player “hop down” from the platform by toggling the collider flag based on user input.

  • @ImmortalTimothyM
    @ImmortalTimothyM Рік тому +10

    Really cool. The movement and animations of that bird is nice as well.

    • @MAGNETO-i1i
      @MAGNETO-i1i 7 місяців тому +2

      Has 3 legs tho 😢

    • @derpzking1833
      @derpzking1833 6 місяців тому

      ur joking about 3 legs right

    • @MAGNETO-i1i
      @MAGNETO-i1i 6 місяців тому

      @@derpzking1833 no.. look closely

  • @RobinRhombus2
    @RobinRhombus2 7 місяців тому +3

    The way I had learnt to solve this is to create a variable to check if you're colliding with the platform or not and if you are, check the y-position until you're above the platform to allow you to pass through or to stop you. I also used this to allow the player to fall through the platform if they're holding down on it.
    This was technically intended for allowing sloped platforms but I never used any because I preferred blocky level design.

  • @cluborronn
    @cluborronn 7 місяців тому +8

    The velocity check or using the normal is probably the most efficient solution here, but another thing you could do is have another bigger collision box around the platform that checks if the bird is above or below it. So it only checks if the bird is near it, instead of all of the time

    • @RamblyBear
      @RamblyBear 7 місяців тому

      Wouldn't it be better to make the player two collision boxes split in the middle. So if players top half hits the platform first he passes through, and if bottom half it's solid. This would also allow for emergent gameplay and exploits by more advanced players.

    • @robertonome2448
      @robertonome2448 7 місяців тому +1

      @@RamblyBear nah. first solution is much cleaner. plus youd still have to do the same check

    • @HashCollision
      @HashCollision 7 місяців тому

      Throwing more hitboxes at it is probably more computationally heavy. (I am assuming engine implementation details here, but it is reasonable in this case) which do you think would cost more? More collision checks, or a Y position check?

    • @robertonome2448
      @robertonome2448 7 місяців тому +1

      @@HashCollision just a standard collision_normal.y check for the default bounding box of the platform (no actual need to have more than 1); if collision_normal.y < 0, collide, else dont. infinitely less costly than checking (amt of platforms) * FPS * (amt of actors) all the time.

  • @iiropeltonen
    @iiropeltonen Рік тому +86

    This sounds perhaps computationally heavy? But a nice solution. I always just checked The direction of vertical velocity.

    • @GrandHighGamer
      @GrandHighGamer 8 місяців тому +16

      It's a completely negligible cost. Anything on screen is already doing a ton of processing just to render, checking a single variable and adjusting its collision state will barely make a difference.

    • @goldencookie5456
      @goldencookie5456 8 місяців тому +5

      Maybe you could only begin the check when the player is colliding (as a trigger) with the collider.

    • @robertonome2448
      @robertonome2448 7 місяців тому +8

      @@GrandHighGamer those stack up tho. its def not a good practice. Plus, using observer-pattern checks - then verifying the collision's normal - for the matter is also much cleaner 99% of the time.

    • @atiedebee1020
      @atiedebee1020 7 місяців тому +1

      ​@@robertonome2448explain how comparing normal vectors decreases the amount of checks and/or is cleaner than comparing the y positions

    • @robertonome2448
      @robertonome2448 7 місяців тому +5

      @@atiedebee1020 collision events... you obviously wont check it at every frame, just during collisions. you cant even check collision normals outside collisions

  • @HerraHissi
    @HerraHissi 7 місяців тому +3

    It's more resource efficient to shift the logic from the static platforms to the moving entities passing torugh. Implement a collision check and snap entities above the tile if they try to pass trough them from above. It also enables more than just one entity to do the same simultaneously as the platforms keep their collision state the same at all times.

  • @Exilum
    @Exilum 7 місяців тому +4

    I didn't something similar in 3D for a end of studies project. Rather than check constantly, which doesn't work at scale, I only checked on collision, and then changed the behavior right away. Because I was on Unity and due to how their collision system is built, I just kept it "on" at all times and disabled it if the collision met my criteria (the call was the first step in handling the collision, and changing it to a trigger simply changed the behavior later in the call chain). I could then just enable it back when the character exited the box.
    One benefit of this approach was that it was not expensive and was still consistent. One drawback is that it was dependent on engine behavior, we couldn't know if another version of unity could break it. But in the context of our project, we could take the risk, as upgrading our unity version wasn't a current or future requirement.

  • @the_furf_of_july4652
    @the_furf_of_july4652 7 місяців тому +16

    Located a bug: if you have an enemy that can jump, they will bonk against any platform lower than the player’s height. Jumping enemies cannot reach the player from below if they are standing on a one way platform

    • @salvadorgonzales1
      @salvadorgonzales1 6 місяців тому +1

      not a bug, more like NOT A FEATURE YET thing

    • @MattTOB618
      @MattTOB618 5 місяців тому

      I think I can think of another problem with this method specifically: what if the one-way platform is tilted in some way? Where on the platform does it compare the player's height to?

  • @cyanicgames5224
    @cyanicgames5224 3 місяці тому +1

    I think it would be better if each entity's script checked if it should collide with platform depending on the Y position, So that the platform collider is always active but player and enemies ignore it if their position is lower. This way both player and enemies could move through the platform and collide with it from above at any time

  • @sirquackz47
    @sirquackz47 6 місяців тому +2

    This actually helps, thank you

  • @olimor1
    @olimor1 5 місяців тому

    I made different collision layers, one collier on the head that doesn’t collide with one-way platforms while body and feet do. when head overlaps with one-way platforms it changes the body and feet colliders to a “head” temporarily and when they exit it (either from jumping over it or falling below it they change back. This leaves less processing power (I think, since it only has to check colliders which it does anyway and not constantly check the Y axis of the player for each platform) and you can add this to enemies so they can jump through too!
    For this the platform needs to be thinner though, otherwise falling through the edges gets a bit wonky
    Another thing is that landing on a platform with your mid-body makes it shake but that’s fixable with side of body colliders that stops positive or negative horizontal movement and in this case because it’s a one-way disables it like the head
    All in all, instead of checking constantly it only checks when it collies followed by a bunch of if statements to determine what to do
    Again, I don’t know if this is better for the cpu but I believe so

  • @timmy180
    @timmy180 Місяць тому

    you can also check if the y-coordinate is lower than the platform, if it gets higher you enable collision, if not, collision is disabled

  • @TrickyMickTrucking
    @TrickyMickTrucking Рік тому +2

    Yes! This is exactly what I'm looking for to create multiple layers for players to go in between like in SMB3! It's my favorite feature of that game!

  • @oscarescobar6876
    @oscarescobar6876 7 місяців тому +1

    I made a type of terrain It is intangible if your movement is upward or if you are inside it, if you stay at the same height or if you move down, the platform is solid. Additionally I made it so that if I pressed jump while crouching my character would check the pixel right below him, if it was this terrain then I would move my character down one pixel, this way I could also go down the platform whenever I wanted.
    Although in my project it was my character who did the terrain checks, not the terrain.

  • @donutdude4174
    @donutdude4174 4 місяці тому

    For new Devs, it's best practices to eliminate unnecessary checks especially every frame all the time.
    In this case, U can use a proximity hitbox to trigger the check.
    Or
    Trigger check on every frame for X time when player jumps. Or when not grounded. Or the moment Y changes.

  • @stealth3122
    @stealth3122 6 місяців тому +1

    You could instead add a collider that sits under the other collider. If player hits the bottom collider make the platform passable otherwise do not.

  • @STNDD
    @STNDD 3 місяці тому +11

    Godot: I don't have such weaknesses

    • @umapessoa6051
      @umapessoa6051 3 місяці тому +5

      Godot sucks, make your own engine and stop depending on shitty things.

    • @Thedarkwaterbun
      @Thedarkwaterbun 2 місяці тому

      @@umapessoa6051L take

    • @Thedarkwaterbun
      @Thedarkwaterbun 2 місяці тому +7

      @@umapessoa6051awful take

    • @obviouslymilk
      @obviouslymilk 2 місяці тому

      @@umapessoa6051cry

    • @umapessoa6051
      @umapessoa6051 2 місяці тому +2

      @@obviouslymilk thanks but i already have 2 well selling games on Steam, good luck on releasing commercial games with Godot 😅

  • @dexlovesgames_dlg
    @dexlovesgames_dlg Рік тому +7

    You should make a follow up demonstrating how to jump down through it. Pretty easy but interesting

    • @nodrance
      @nodrance 7 місяців тому

      If you hold down for a second, or down+jump, or whatever, then disable the collision until you're outside of it

  • @thisguy.-.
    @thisguy.-. 7 місяців тому

    2 things:
    One - I really like how you explain how it works (fundamenrally atleast) instead of just giving tutorials with pre-made assets, learning how to demystify black box game logic is a huge part of advanced game dev and I love it
    Two - as far as your solution goes, I won't say its performance problematic unlike other people, I think it's just fine for the scope of the project. But I would like to suggest that a more individual approach that focuses on general game objects instead of just the player would boost level and enemy design ability since it would allow enemy AI to take advantage of the game mechanic which is kinda hard but super worth it

  • @DqwertyC
    @DqwertyC 6 місяців тому

    For anyone using Unity concerned about efficiency, this is a perfectly valid solution, and is more efficient than using a PlatformEffector (unless you want some of the extra bells and whistles PlatformEffector provides). If you want, you could also split the collider in 2, and have one be a trigger that disables the other one, which is about on par with this CPU usage wise.
    Most of the complaints about efficiency assume your engine lets you intercept the collision and choose to ignore it before the effects are applied, which Unity doesn't seem to allow, at least in what I've found.

  • @kuobah
    @kuobah 6 місяців тому

    Immediately went into the comments as soon as I heard "platforms constantly checking if character is above or not"

  • @elHonguito
    @elHonguito 3 місяці тому

    I have another solution that doesn't involve platforms checking on every frame
    Instead of using a box shaped collider, use a plane or a quad as a collider. Planes and Quads by default are one sided objects, being the front face the one with the collision, so if the player goes through it from below, it would ignore it until the player stands on top

  • @srqubit9480
    @srqubit9480 Рік тому +24

    for my games I use the method of
    If Yspeed > 0 :
    it will be traversable and
    if Yspeed

    • @srqubit9480
      @srqubit9480 Рік тому

      I use python and pygame

    • @hiiambarney4489
      @hiiambarney4489 Рік тому

      So what if you start falling exactly as you traverse the collider?

    • @nightwintertooth9502
      @nightwintertooth9502 10 місяців тому

      ​​​​@@hiiambarney4489good use case for fixedupdate to catch it before the next frame. Race conditions are fixed by correctly ordering physics checks. In good patrern uodate should never check or update physics it is on a different framerule entirely so this couldnt happen. 😊

    • @cheekygiraffe9848
      @cheekygiraffe9848 10 місяців тому +1

      i have an odd urge to think scratch code

    • @tPlayerioT
      @tPlayerioT 9 місяців тому

      ​@@hiiambarney4489could be there a check if collider is still inside the static body

  • @sparklee82
    @sparklee82 5 місяців тому +1

    Imagine doing it this way but for multiplayer. Ya u gonna get alot of bugs. But this is perfect for a singleplayer

  • @Darkwolfsbane
    @Darkwolfsbane 3 місяці тому

    This'll definitely help. Making a metroidvania, and if you want to know how many of these are in one, play through one and take a drink for every new one you see.

  • @JF-um3wz
    @JF-um3wz 7 місяців тому

    See, when I tried this way back when for a high school class, I tried solving it by using the motion that you can have upward movement through it, but not downward. The flaw with that design choice is that a player or entity can be partway through a platform like this, which can result in clip-based glitches.
    By having the platform be in a different state depending on position of the entity it effects, this problem is entirely avoided. This is a really helpful solution to view the problem with!

  • @iRedEarth
    @iRedEarth 7 місяців тому

    I remember going from Super Mario Bros. to SMB2 and this was a big effing deal! Also, top down games having 8 directions instead of just 4. Kids these days will never know how mind-blowing these minor technological improvements were.

  • @nonexistent2341
    @nonexistent2341 7 місяців тому +1

    This lil birb is so cute!

  • @adrianbunea2006
    @adrianbunea2006 7 місяців тому +1

    Each object checking your height means a lot of computing. You could have the player check when it's colliding with the platform wether it's above or not. You would only need to check for one node (player) only once, at collide event

  • @kaloyantoskov6818
    @kaloyantoskov6818 3 місяці тому +5

    Meanwhile Godot laughing at you

  • @cassandracollins4150
    @cassandracollins4150 8 місяців тому +1

    Should make it more dynamic and any sprite that is below it ignores the collision, rather than changing the platform can't the interaction between the spirits and the platform

  • @The-EJ-Factor
    @The-EJ-Factor 5 місяців тому +1

    In my games I just check if the y momentum is greater than 0 then it doesn’t collide.

  • @thepenguin9
    @thepenguin9 7 місяців тому

    If you're watching the video and stuck on how to implement it:
    Set the collision to disable when the *bottom* of the player's hitbox Y-level is below the *top* of platform's hitbox Y-level

  • @NadalynTheSequel
    @NadalynTheSequel 7 місяців тому

    Only reason i posted this was bc i like the strings and you can hear them better here ok gn

  • @TheCuteKyuubi
    @TheCuteKyuubi 6 місяців тому +1

    However if you want this to work for multiplayer, you can instead use a Y speed check to see if the targeted plater is moving up or down

  • @kytkeyboardsyoureterrific439
    @kytkeyboardsyoureterrific439 7 місяців тому

    Cool! I love learning about games

  • @tomasgoes
    @tomasgoes 7 місяців тому +9

    Making Yandere dev proud.

    • @chloespades
      @chloespades 5 місяців тому +2

      "God I wish there was an easier way to do this"

  • @hogandromgool2062
    @hogandromgool2062 6 місяців тому

    This could become quite expensive. The best ways to do this is to disable player collisions when jump is active OR check if the player's directional heading is up, if so we disable the collision also.

  • @WooperZzz
    @WooperZzz 6 місяців тому +1

    If you have a lot of these checking every one constantly could be bad for frames and unoptimised. You could add an area where these get checked, so its not slowing performance

  • @carson2889
    @carson2889 7 місяців тому +1

    could just make a custom collider script for those platforms that adds a check on collision enter to see whether it was the player that collided and, if so, whether they are above or below the platform. Cuts down heavily on checks per minute and should still provide exactly the same functionality.

  • @TuberTugger
    @TuberTugger 3 місяці тому

    love me some "always checking" platforms that totally scale with the size of the project.

  • @morrisroberti1205
    @morrisroberti1205 3 місяці тому

    This is clearly a naive way to do it but I really like these reels where you explain this basic things on gamedev by example, keep doing this plz

  • @studybruh
    @studybruh 3 місяці тому

    Gosh I Was thinking about the mechanism behind this thanks a lot

  • @user-bv6bl5im7u
    @user-bv6bl5im7u 6 місяців тому

    Well if there ever is an enemy capable of jumping to chase you more effectively it could also fall through a platform intentionally (maybe only after the player touches the ground) as a way to keep chasing or to kill/get rid of the enemy if something related is below

  • @Xarxes104
    @Xarxes104 7 місяців тому

    That's trippy, much like the earlier contra games

  • @_anlim309
    @_anlim309 7 місяців тому +3

    This might be a dumb question, but isn't this potentially a major performance issue? Since every collision is checking the player position at all times?

  • @bluematter435
    @bluematter435 7 місяців тому

    eyy this is a case where it makes sense to have the origin of the player at the bottom of their feet,
    but you of course can also do it with an empty, if say you wanted the player sprite to rotate from the middle and not from the bottom

  • @ITYWTD_
    @ITYWTD_ 20 днів тому

    Unity has a component just for this! Pretty cool!

  • @koenthiessen-qz1ez
    @koenthiessen-qz1ez 18 днів тому

    you could put a trigger box under the platform so jumping enemies could use it

  • @rokaq5163
    @rokaq5163 7 місяців тому

    I'm sure this could be handled more efficiently, since constant checks stacked on top of each other will take a toll on your game's performance. I won't pretend I am a game programmer, but I did learn to program robots back at uni, and stacking checks on a looping function is never ideal. If anyone has a nicer way of doing it without needing as much computer power, I'd be very glad to know!

  • @LauLauHip
    @LauLauHip 6 місяців тому

    I'd probably be more efficient to disable collisions if the velocity of the player is upwards, that way you don't have to perform as many checks

  • @trajectoryunown
    @trajectoryunown 6 місяців тому

    This just gave me an idea for a simple game.
    Thank you!

  • @LapizMsI0
    @LapizMsI0 6 місяців тому

    Instructions unclear: birb has been stuck when i came from the side

  • @ThijsDaniels
    @ThijsDaniels 7 місяців тому

    Next to the compute needed for constantly checking, this approach also means the player will still collide with the sides of the platform. Better to use a line instead. (Although jf the player's speed is ever expected to exceed its own collider's height per frame, you'd need raycasts to prevent the player from clipping through, but you may need that even with box colliders)

  • @ahmedalhawar595
    @ahmedalhawar595 7 місяців тому

    Or you can set the collision of the platform to be no collision, add a collision box ontop of the platform block. Once the play is touching that collision, set collision to normal, once they stop touching it then set it back to no collision.

  • @nikolacatlak9875
    @nikolacatlak9875 6 місяців тому

    another cool frsture you should include is holding down and pressing jump to fall through the platform

  • @archcynic404
    @archcynic404 7 місяців тому

    That’s insane! I’m sure everyone is playing your game and is the next game of the year because you posted this short. Truly best info of all time

  • @ahmed4363
    @ahmed4363 7 місяців тому

    Today is finally the day i can say Geometry Dash as an example of these one way platforms

  • @tycho25
    @tycho25 4 місяці тому

    I had never thought of doing it this way. Pretty cool.

  • @qcubic
    @qcubic 7 місяців тому

    There may be a problem, but I'm not sure.
    If the collision is based on the center of mass of the player, it could lead to clipping issues on the edge of platforms.
    If it's based on the bottom of the player's collision box, there could be issues with multiple platforms strung in series.
    All in all, it's a great looking game and collision concept.

  • @MrJonh95
    @MrJonh95 7 місяців тому

    Back in dev school I was doing a 2d game in ue4. The solution I found was to check if the character vertical velocity was positive. If it was then it would ignore collision, but if was negative or equal to 0 then it would block collisions. Jenky but it worked :D

  • @lorenzogiuliani3724
    @lorenzogiuliani3724 7 місяців тому

    Overcomplicated solution:
    Take the direction vector of the platform (up) and the vector from the player to the platform, normalize them and do the dot product, if its positive enable collider if its negative disable

  • @flowrling
    @flowrling 7 місяців тому

    in my most recent WIP game, i wanted to make oneways in different directions, so instead of making four objects (onewayUp, onewayDown, etc), i just made one that does trig to check the players distance in relation to its angle and face.
    sounds complicated, but it was simple enough, and had the added benefit of working in ALL 360 degrees

  • @aaroneasterling1044
    @aaroneasterling1044 7 місяців тому

    Mario land music is such a good choice 😊

  • @kaw57_
    @kaw57_ 4 місяці тому

    or alternatively you could have them wait for a signal that the player's y position is changing to check if they should be solid, which i imagine would be slightly better for performance

  • @gegart01
    @gegart01 5 місяців тому

    Thank you, brother

  • @ethansmit159
    @ethansmit159 Рік тому +6

    Holy crap man thanks.
    I'm working on a platformer right now and was stuck on just that issue.
    I thought I could just go around platforms, but the level design is making that difficult.
    Thanks again.

    • @antiktestere
      @antiktestere Рік тому +1

      release it bro

    • @spell105
      @spell105 7 місяців тому

      If this is what you got stuck on, and you saw this solution and thought "Wow that's a good solution", you shouldn't be making games. Go learn some basic math and programming instead. And I do mean BASIC.

    • @readyorgormotti4695
      @readyorgormotti4695 7 місяців тому +2

      ​@@spell105 person who thinks all true game devs are born with a gene that lets them detect poor coding practice intuitively, without gaining experience first, like some kinda gaming spider sense
      sorry op you werent born with the power of game dev etched into your soul, better give up on your dreams!

    • @Orenshaii
      @Orenshaii 7 місяців тому +2

      @@spell105I’d argue that trying to make a game is a good way to learn those things. People don’t have to be masters at their craft before they’re allowed to try to make something cool, and it often helps when figuring out what skills have been mastered and what needs to be improved. Op is doing just fine.

    • @markkealy4417
      @markkealy4417 6 місяців тому

      @@spell105 you kinda suck as a person right now, introspect before you lose all your friends

  • @AbsCmp
    @AbsCmp 4 місяці тому

    I literally spent an hour trying to figure it out and then I opened my phone to take a rest and this video showed up

  • @JolanXBL
    @JolanXBL 6 місяців тому

    Very Dreamland esque music ^_^

  • @imas9121
    @imas9121 7 місяців тому

    I will (probably) never use this information but that's super cool anyway lol.

  • @jhgvvetyjj6589
    @jhgvvetyjj6589 5 місяців тому

    Or if floor collision and ceiling collision is handled separately then one way platforms only use one of them, similarly horizontally for left collision and right collision

  • @enesemreislek4264
    @enesemreislek4264 20 днів тому

    Or you can simply send a raycast to upper your character. If raycast hits any platform you can ignore platforms collider with player. İf you want to go down simply check that players input is going to downwards then check is player colliding with any platform, than reach the platform and say the same thing with the raycast. Ignore the collision between player and platform. and you have to start a timer for platform to turn back to normal

  • @ssbmbardon
    @ssbmbardon 7 місяців тому

    butter building my beloved

  • @BobzBlue
    @BobzBlue 7 місяців тому +1

    Im just thinking of the place sound effect in mario maker, "semi-solid platform"

  • @DarthTaterz7
    @DarthTaterz7 6 місяців тому

    Very helpful my guy!

  • @BederatziDokuz
    @BederatziDokuz 6 місяців тому

    I don't know how it works in terraria, but now that I've seen this video I think the collision that changes is that of the entity and not the platform and that's why you can go through walls of 1 block thick.

  • @lightknightgames
    @lightknightgames 5 місяців тому

    Or you can just check the line of contact.
    It means you have to run in an engine that doesn't use micro sub-pixels, because you'll get glitches every now and then (like the mario speedruns)
    But that's super easy to do.

  • @flaviofael
    @flaviofael 7 місяців тому

    In unity you can just use a platform effector and configure it to work this way, it can even include a falling effect where the player can go through the platform downwards jumping and pressing down button

  • @Zanarkand_0
    @Zanarkand_0 6 місяців тому

    Always wondered how they did that. Thanks

  • @Kwauhn.
    @Kwauhn. 7 місяців тому

    You could also achieve this by giving the bounding box a normal vector to compare to the player's velocity during collision checks.

  • @OmarElmasry1
    @OmarElmasry1 6 місяців тому

    Ok, now i want to play your game.

  • @KDYinYouTube
    @KDYinYouTube 5 місяців тому

    this is one of the example that 3D movement played in 2D world.

  • @Klaxynd
    @Klaxynd 6 місяців тому

    I forgot exactly how I did this in unity, but I’m pretty sure I used a physics layer mask and a check on the player’s y velocity. If it was positive, you could go through certain platforms. If it was 0 or less you would stand on the platform. I also had a caveat for if you pressed down to fall through. I may have overcomplicated things, but constantly checking whether or not you’re above or below each platform in the scene each frame seems like overkill even to me.
    (In the project I was working on I also needed said platforms to be able to be fallen through if you pressed down like in SmaBro. I’m curious to see how others solved/would solve this.)

  • @JamAttack
    @JamAttack 7 місяців тому

    this probably depends on how much control you have over your platformer physics, but I'd probably just remove the side wall collisions entirely just in case

  • @SISYPHEgame2
    @SISYPHEgame2 7 місяців тому +1

    That's cool and all, but why is every single programmer in here just ignoring that there is a complete different collision type that you can assign as a component to an object. I believe it's called the platform effector. This is all for Unity of course.

  • @oxintoma32dev
    @oxintoma32dev 7 місяців тому

    Yo this is helpful, thanks man

  • @ParmEsanXP
    @ParmEsanXP Рік тому

    This was more helpful then you can imagine

  • @Zellonous
    @Zellonous 7 місяців тому

    Pet peeve: no down jump on platforms in certain games.

  • @EtherealKiri
    @EtherealKiri 8 місяців тому

    If you want an effect like in kirby where you can go through by crouching you can have your hitbox shift down to collide with the platform, it would immediately make it passable even though you were above