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

Поделиться
HTML-код
  • Опубликовано: 21 окт 2024

Комментарии • 767

  • @ghb323
    @ghb323 2 года назад +6500

    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 Год назад +357

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

    • @ghb323
      @ghb323 Год назад +204

      @@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 Год назад +15

      i did like that.

    • @WellDressedMuffin
      @WellDressedMuffin Год назад +480

      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 10 месяцев назад +2963

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

    • @tomasgoes
      @tomasgoes 9 месяцев назад +290

      Optimisation? What's that?

    • @Betterthenyou375
      @Betterthenyou375 9 месяцев назад +320

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

    • @Pluto-ek3mh
      @Pluto-ek3mh 9 месяцев назад +95

      What would be the optimal way of going about this?

    • @baronbacku9984
      @baronbacku9984 9 месяцев назад +215

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

    • @atiedebee1020
      @atiedebee1020 9 месяцев назад +8

      What's wrong with the video?

  • @Stevejustt
    @Stevejustt 10 месяцев назад +1597

    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 10 месяцев назад +83

      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 10 месяцев назад +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 10 месяцев назад +110

      @@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 10 месяцев назад +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 9 месяцев назад +1

      Have it detect the player by proximity

  • @the-rudolph
    @the-rudolph 3 года назад +898

    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 года назад +154

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

    • @michaeldiaz4285
      @michaeldiaz4285 2 года назад +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 Год назад +36

      ​@@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 10 месяцев назад +2204

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

    • @makotomiyamoto5249
      @makotomiyamoto5249 10 месяцев назад +35

      Could you explain?

    • @DARK_AMBIGUOUS
      @DARK_AMBIGUOUS 10 месяцев назад +70

      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 10 месяцев назад +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 10 месяцев назад +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 10 месяцев назад +89

      ​@@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 10 месяцев назад +33

    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 9 месяцев назад +15

      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 8 месяцев назад +4

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

    • @FerousFolly
      @FerousFolly 8 месяцев назад +4

      @@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.

  • @thneitor
    @thneitor 10 месяцев назад +41

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

    • @DEVdreamweaver
      @DEVdreamweaver 8 месяцев назад +2

      what about if you're coming from the side?

    • @thneitor
      @thneitor 7 месяцев назад +2

      @@DEVdreamweaver You don't.

  • @CallMeCasper_
    @CallMeCasper_ Год назад +135

    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 9 месяцев назад +8

      Unity 😂

    • @gamezboi_
      @gamezboi_ 9 месяцев назад +3

      @@autoimmunedefficiencysyndrome wts wrong w/ unity

    • @Fishlady143
      @Fishlady143 9 месяцев назад +13

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

  • @kaboomsihal1164
    @kaboomsihal1164 Год назад +432

    In godot I just check "one way collision" lol

    • @bubi1909
      @bubi1909 Год назад +38

      Works in unity too with effector

    • @scrunky8683
      @scrunky8683 Год назад +7

      any tutorials for that

    • @kaboomsihal1164
      @kaboomsihal1164 Год назад

      @@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 Год назад +16

      of course, Godot has anything you may think of

    • @mouinhizem1428
      @mouinhizem1428 11 месяцев назад +4

      go dot for kids
      Lmao

  • @RobinRhombus2
    @RobinRhombus2 9 месяцев назад +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.

  • @austindrexler2092
    @austindrexler2092 4 месяца назад +4

    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 9 месяцев назад +2

      Has 3 legs tho 😢

    • @derpzking1833
      @derpzking1833 8 месяцев назад

      ur joking about 3 legs right

    • @MAGNETO-i1i
      @MAGNETO-i1i 8 месяцев назад

      @@derpzking1833 no.. look closely

  • @mudsp1ash
    @mudsp1ash 10 месяцев назад +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.

  • @sirquackz47
    @sirquackz47 8 месяцев назад +2

    This actually helps, thank you

  • @Exilum
    @Exilum 9 месяцев назад +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.

  • @HerraHissi
    @HerraHissi 9 месяцев назад +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.

  • @cluborronn
    @cluborronn 10 месяцев назад +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 9 месяцев назад

      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 9 месяцев назад +1

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

    • @HashCollision
      @HashCollision 9 месяцев назад

      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 9 месяцев назад +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.

  • @TuberTugger
    @TuberTugger 5 месяцев назад

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

  • @thisguy.-.
    @thisguy.-. 9 месяцев назад

    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

  • @BananaMan6763
    @BananaMan6763 Месяц назад

    This is very useful and helps to show that when coding features you just need to think logically enough. Just see if the player is below the platformer and if so then turn the collision off, else, turn it on. I can imagine using this in some of my games.

  • @the_furf_of_july4652
    @the_furf_of_july4652 9 месяцев назад +17

    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 8 месяцев назад +1

      not a bug, more like NOT A FEATURE YET thing

    • @MattTOB618
      @MattTOB618 8 месяцев назад

      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?

  • @zebede38
    @zebede38 9 месяцев назад +20

    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 9 месяцев назад +6

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

  • @dexlovesgames_dlg
    @dexlovesgames_dlg Год назад +7

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

    • @nodrance
      @nodrance 10 месяцев назад

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

  • @sparklee82
    @sparklee82 7 месяцев назад +1

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

  • @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!

  • @iiropeltonen
    @iiropeltonen Год назад +88

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

    • @GrandHighGamer
      @GrandHighGamer 11 месяцев назад +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 10 месяцев назад +5

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

    • @robertonome2448
      @robertonome2448 9 месяцев назад +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 9 месяцев назад +1

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

    • @robertonome2448
      @robertonome2448 9 месяцев назад +5

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

  • @trajectoryunown
    @trajectoryunown 8 месяцев назад

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

  • @oscarescobar6876
    @oscarescobar6876 10 месяцев назад +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.

  • @Darkwolfsbane
    @Darkwolfsbane 5 месяцев назад

    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.

  • @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 Год назад

      ​​​​@@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 Год назад +1

      i have an odd urge to think scratch code

    • @tPlayerioT
      @tPlayerioT Год назад

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

  • @The-EJ-Factor
    @The-EJ-Factor 7 месяцев назад +1

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

  • @donutdude4174
    @donutdude4174 6 месяцев назад

    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.

  • @kuobah
    @kuobah 8 месяцев назад

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

  • @olimor1
    @olimor1 8 месяцев назад

    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

  • @tycho25
    @tycho25 6 месяцев назад

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

  • @JamAttack
    @JamAttack 9 месяцев назад

    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

  • @JF-um3wz
    @JF-um3wz 9 месяцев назад

    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!

  • @cyanicgames5224
    @cyanicgames5224 5 месяцев назад +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

  • @thepenguin9
    @thepenguin9 9 месяцев назад

    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

  • @timmy180
    @timmy180 3 месяца назад

    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

  • @nonexistent2341
    @nonexistent2341 9 месяцев назад +1

    This lil birb is so cute!

  • @elHonguito
    @elHonguito 6 месяцев назад

    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

  • @morrisroberti1205
    @morrisroberti1205 5 месяцев назад

    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

  • @AbsCmp
    @AbsCmp 6 месяцев назад

    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

  • @kytkeyboardsyoureterrific439
    @kytkeyboardsyoureterrific439 9 месяцев назад

    Cool! I love learning about games

  • @ThijsDaniels
    @ThijsDaniels 9 месяцев назад

    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)

  • @cassandracollins4150
    @cassandracollins4150 10 месяцев назад +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

  • @MrJonh95
    @MrJonh95 9 месяцев назад

    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

  • @iRedEarth
    @iRedEarth 9 месяцев назад

    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.

  • @adrianbunea2006
    @adrianbunea2006 10 месяцев назад +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

  • @ParmEsanXP
    @ParmEsanXP 2 года назад

    This was more helpful then you can imagine

  • @hogandromgool2062
    @hogandromgool2062 8 месяцев назад

    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.

  • @Xarxes104
    @Xarxes104 9 месяцев назад

    That's trippy, much like the earlier contra games

  • @DqwertyC
    @DqwertyC 9 месяцев назад

    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.

  • @Kwauhn.
    @Kwauhn. 9 месяцев назад

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

  • @stealth3122
    @stealth3122 9 месяцев назад +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.

  • @studybruh
    @studybruh 5 месяцев назад

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

  • @carson2889
    @carson2889 10 месяцев назад +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.

  • @Grass11111
    @Grass11111 Месяц назад

    Tutorial: 👍
    Butter building: 🎶 🎶 🎶

  • @oxintoma32dev
    @oxintoma32dev 9 месяцев назад

    Yo this is helpful, thanks man

  • @flowrling
    @flowrling 10 месяцев назад

    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

  • @glass_eater11
    @glass_eater11 2 месяца назад

    Unity has a component just for this! Pretty cool!

  • @LapizMsI0
    @LapizMsI0 8 месяцев назад

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

  • @DarthTaterz7
    @DarthTaterz7 8 месяцев назад

    Very helpful my guy!

  • @ignaciolopez8597
    @ignaciolopez8597 11 часов назад

    Despite this, that make a lot of calculation when you have thousands of platforms, try use a raycast from top player to down platform, up, and a down player to top platform, down, disable the players collider until the other raycast, the one that did not register the collision, detects the other part of the platform, finally enable the players collider

  • @nutwit1630
    @nutwit1630 8 месяцев назад

    Now i'm imagining a system where just the player shoots out a little "jump bullet" whenever you press the jump button, which tries to collide with an object and, if it does, reads information about the object's position and context, and then tells the player how to jump

  • @DJCheese77
    @DJCheese77 10 месяцев назад +1

    this looks like a two way platform, gonna be honest. If I was playing this game I would assume you can fall down from this and be mildly irritated to find out this is the one way platform in this game.

  • @flaviofael
    @flaviofael 9 месяцев назад

    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

  • @daleodorito
    @daleodorito 9 месяцев назад

    I would add an extra trigger collider below the platform to check if the player is in there and while it is, remove the collision of the platform

  • @arkin0x
    @arkin0x 9 месяцев назад

    this is helpful! thank you!

  • @nikolacatlak9875
    @nikolacatlak9875 9 месяцев назад

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

  • @qcubic
    @qcubic 9 месяцев назад

    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.

  • @TheCuteKyuubi
    @TheCuteKyuubi 8 месяцев назад +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

  • @lordofdarkfate538
    @lordofdarkfate538 9 месяцев назад

    First thing i programmed was sth like this in BlueJ with boxes and a ball, i didn't even know you could call those hitboxes XD
    Really cool btw

  • @gegart01
    @gegart01 8 месяцев назад

    Thank you, brother

  • @LuminousLead
    @LuminousLead 9 месяцев назад

    I like the bird animation.

  • @cracked_smith-qz1ez
    @cracked_smith-qz1ez 2 месяца назад

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

  • @fuylro6r6or6pg6p
    @fuylro6r6or6pg6p 9 месяцев назад

    Interesting way to solve it, wasn't the first that came to mind.

  • @LauLauHip
    @LauLauHip 8 месяцев назад

    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

  • @aaroneasterling1044
    @aaroneasterling1044 9 месяцев назад

    Mario land music is such a good choice 😊

  • @WooperZzz
    @WooperZzz 9 месяцев назад +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

  • @ΠαντεληςΜεϊμετης-ν4ω
    @ΠαντεληςΜεϊμετης-ν4ω 8 месяцев назад

    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

  • @Daftless
    @Daftless Год назад

    I've read how to make one way platforms and it didn't exactly click fully what I was doing until just now, thanks a lot

  • @JolanXBL
    @JolanXBL 9 месяцев назад

    Very Dreamland esque music ^_^

  • @EtherealKiri
    @EtherealKiri 11 месяцев назад

    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

  • @halfling.2344
    @halfling.2344 5 месяцев назад

    Platform effector in unity and one way collision in godot solves this easyly. This makes so much work for system

  • @Zanarkand_0
    @Zanarkand_0 8 месяцев назад

    Always wondered how they did that. Thanks

  • @paulvictor7489
    @paulvictor7489 10 месяцев назад

    I feel like watching this I also lerned how clipping works.

  • @bluematter435
    @bluematter435 9 месяцев назад

    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

  • @_anlim309
    @_anlim309 9 месяцев назад +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?

  • @BederatziDokuz
    @BederatziDokuz 9 месяцев назад

    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.

  • @lorenzogiuliani3724
    @lorenzogiuliani3724 9 месяцев назад

    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

  • @ahmedalhawar595
    @ahmedalhawar595 9 месяцев назад

    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.

  • @kadabra8
    @kadabra8 Год назад

    Люблю ці міні новинки) дізнаюсь багато нового для себе)

  • @imas9121
    @imas9121 9 месяцев назад

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

  • @kaw57_
    @kaw57_ 6 месяцев назад

    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

  • @janoslambert-cannon7146
    @janoslambert-cannon7146 8 месяцев назад

    Far better to just check if the players y velocity is downwards rather than comparing their y coordinate to every platform in the level every single frame

  • @rokaq5163
    @rokaq5163 9 месяцев назад

    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!

  • @KDYinYouTube
    @KDYinYouTube 7 месяцев назад

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

  • @OmarElmasry1
    @OmarElmasry1 8 месяцев назад

    Ok, now i want to play your game.