3 Unity Tricks: Gravity Wells, Right Angle Flips, and Moving Platforms

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

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

  • @git-amend
    @git-amend  5 месяцев назад +5

    Happy Sunday! Lots of new tips and tricks today, and also I've updated the Unity Utility Library with some new hotkeys and helpers! Link in description!

    • @Fitz0fury
      @Fitz0fury 5 месяцев назад +3

      The audacity of you to launch this the week after I implement this exact stuff! This is still super cool and I'm glad you did something like this. As is tradition I now have to know that I spent 2 weeks implementing a new thing only for you to casually write a better version of it.

    • @git-amend
      @git-amend  5 месяцев назад

      @@Fitz0fury I think we need to sync up so I can get your timetable...

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

      @@git-amend ill ping you later. I have made an insane amount of progress. I could actually use your advice about my next stage. The dreaded "final rework" of the battle system is coming up.

    • @Fitz0fury
      @Fitz0fury 5 месяцев назад +1

      @@git-amend for the record silly gravity was not part of my scope. But I ended up going down a character controller rabbit hole for a few weeks ..all because I had started causing some conflicts between old code where i was handling interactions without using an interactable interface and an asset I use for its inventory database.

  • @PsigenVision
    @PsigenVision 5 месяцев назад +6

    I have never clicked a video so fast. This is PRECISELY the hurdle my game is focusing on right now with the Gravitas asset-creator.
    Lol I say this before even proceeding with the video because that is how much I trust git-amend. XD

    • @git-amend
      @git-amend  5 месяцев назад +2

      Lol well I hope it helps you out! Though I think this is a bit different than the Gravitas asset, though I’m not really familiar with it.

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

      @@git-amend You might be right XD I might have let my excitement take over a little bit back there. 😅 STILL related though! I'm excited!

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

    These are the kind of video on topics that you usually spend hours trying to figure out how to do, thanks a lot.
    An suggestion for future video is the vector math used in the gravity well. I remember it gave me hard time to build up a mental modal to assimilate the math. With your teaching style, It can be amazing!

    • @git-amend
      @git-amend  4 месяца назад

      Good idea, a few others have asked about Vector Math as well. Cheers!

  • @techdave99
    @techdave99 5 месяцев назад +2

    This is a great video. I'm working on a character controller and might use this. Still working out if I want a rigidbody or not.

    • @git-amend
      @git-amend  5 месяцев назад +2

      Nice. I usually find that it's more useful to have one, but I almost always take full control of it. The main reason is so I can have collisions without requiring rigidbodies on all the other objects.

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

    Great video. Really fun mechanics here, I will be trying them out today. Also I like that addition to the utility library, after you mentioned that you don't like the new command in coroutines that got me thinking about that as well, I had not considered that a possible issue before, and the WaitFor feels cleaner. Looking forward to the advanced character controller. Thanks git!

    • @git-amend
      @git-amend  4 месяца назад

      Sounds good! Thanks for the comment! I agree, the WaitFor is definitely cleaner.

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

    What a fantastic video, so well explained and executed. thanks for the lesson!

    • @git-amend
      @git-amend  4 месяца назад

      You're very welcome!

  • @uhhmir
    @uhhmir 5 месяцев назад +1

    cant wait for a character controller episode!

    • @git-amend
      @git-amend  5 месяцев назад +1

      Coming soon!

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

      @@git-amend Awesome, I hope it's third person controller with rigibody!

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

    Amazing stuff as always Git-Amend 🤝

    • @git-amend
      @git-amend  5 месяцев назад +1

      Much appreciated

  • @VladaPersonal
    @VladaPersonal 5 месяцев назад +1

    Keep going, great work!❤

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

    Hi Adam, maybe you could do a video one day on your recommended most-needed/useful assets to buy?? For example, I am wondering if I should purchase Odin Inspector , and the importance of doing so..... cheers

    • @git-amend
      @git-amend  4 месяца назад +1

      That is actually the subject of next week's video!

  • @Thomas-yz3ny
    @Thomas-yz3ny 5 месяцев назад

    Danke!

    • @git-amend
      @git-amend  5 месяцев назад +1

      Thanks for the super!

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

    Great work! Keep it up!

    • @git-amend
      @git-amend  5 месяцев назад

      Thanks, will do!

  • @profzeta8598
    @profzeta8598 5 месяцев назад +2

    you could add a script that takes any moving platform velocity and adds it to the character controller as additional force. as conservation of momentum.
    i.e you jump from one train car to another train car. without suddenly being de-parented or float off the moving platform.

    • @git-amend
      @git-amend  5 месяцев назад

      I like that idea! Will play around with that later, cheers!

  • @정동우-n2x
    @정동우-n2x 4 месяца назад

    It really helped me.

    • @git-amend
      @git-amend  4 месяца назад +1

      Glad to hear it!

    • @정동우-n2x
      @정동우-n2x 4 месяца назад

      @@git-amend always Thanks! Teacher

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

    Hello, Thank you so much for these Videos... I am very new to Unity and I have learned so much already thank to your channel. I was wondering if there was a place where you were publishing the entire project (Assets included)?

    • @git-amend
      @git-amend  3 месяца назад

      Thanks for watching! A link to the code (which is free when available) will be in the video description. There will also be links to most Assets used, which is usually a mix of free and paid Assets from the Unity Asset Store. Because most videos use paid Assets, there will rarely be a complete project for you to download.

  • @Antony14021894
    @Antony14021894 5 месяцев назад +1

    Great video as usual!
    What happens if you jump while in the gravity well and are upside down?

    • @git-amend
      @git-amend  5 месяцев назад +1

      Thanks! If you jump in the well, you'll get pulled in the downward direction of the player - that's a function of the player controller script though, which we'll get into in an upcoming video. You can see it on my Twitter feed here: x.com/AdamMyhre1/status/1814878970409824446

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

      @@git-amend Great, thanks!

  • @techdave99
    @techdave99 5 месяцев назад +1

    Hope the move goes well and the flight is on time.

    • @git-amend
      @git-amend  5 месяцев назад

      Me too! Thanks! I'm all set to go.

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

    Great video. This one helped me with one of the issues I was facing. Is there a way to alter gravity with arrow keys so that we can flip the player gravity in any of the directions(Up, Left Right, Down) and allow normal movements on those surfaces?

    • @git-amend
      @git-amend  4 месяца назад

      Thanks! I think if you want to do that you need to disable gravity of course on the rigidbody and then start applying your own force in a particular direction, usually coming from the player's transform.position.up direction. We're actually going to look at that a bit this weekend.

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

      @@git-amend thanks for the tip, I'll look forward to this week's video. I tried doing the gravity manipulation with Vector3.up / left / right and so on which was a success but the player movement gets messed up in turn.

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

    Could you do a video on how to make own our navmesh system? Unity's is lacklustre and the asset store options are great but are quite overkill. I would love to learn to make my own but it seems very advanced and complicated especially run time stuff.

  • @6Abdellah9
    @6Abdellah9 4 месяца назад

    amazing video as always. can i ask for a future video fro you to make sone sort of loadout system were you could have a gun for example and pick between attachments and this is updated at runtime and is saved too as I know with scriptable objects they cannot be changed at runtime. i have tried making a system but it just doesn't feel good I'm hoping you have an amazing solution as always

    • @git-amend
      @git-amend  4 месяца назад

      Thanks! That's not a bad idea, I'll jot that one down!

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

    That's so cool

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

    What are your thoughts on tweening libraries (i.e. DOTween)? I'm a bit surprised that I haven't seen you use DOTween in your videos yet. You'd be able to rewrite the moving platform script to be *much* smaller and easier to read (albeit with a small performance hit, naturally).

    • @git-amend
      @git-amend  4 месяца назад

      Actually I've really been getting into PrimeTween lately for it's ease of use and zero allocations;, I've all but retired DOTween. As far as using it for Platforms, of course that's a great solution as well. Maybe I'll show an updated version when we get to the video about the Controller in a few weeks.

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

      @@git-amend Oh I haven't heard of PrimeTween. Thanks for the rec!

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

    You could also use the improvisedTimers you did before to create custom fixedupdate that also follow the same workflow you did in here, as well to be able to turn the "updating" off when we know its in no use.
    Would that be a thing worth doing? that way the coroutine wouldnt be playing at all times

    • @git-amend
      @git-amend  5 месяцев назад +1

      You could do that yes, but it might introduce another level of complexity that - in this case at least - is not necessary since a MonoBehaviour / Coroutine combination already provides all the functionality that we need. If you needed to make some kind of more complex platforms, you could consider doing that. Just remember the extra complexity has to be justifiable, so always ask yourself what problem you need to actually solve that requires the more difficult solution.

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

      @@git-amend Appreciate the reply, i really didnt considered the complexity being an issue, since the way i thought about it is that after being used to work with them, it wouldnt be that hard to do.
      Keep the good work!

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

    Interesting, I would have expected that the gravity well component could basically have handled the right angle flip situation as well. It probably can when we change the center calculation to instead use a plane projection for direction. But the way you showed is simpler.
    Looking forward to the player controller video(s). I always struggle with those.
    Do you know why is the new waitforfixed update not static to begin with? I always thought the amount of time to wait might not be the same between frames or sth like that.

    • @git-amend
      @git-amend  5 месяцев назад +1

      Thanks for the comment, and the excellent question. WaitForFixedUpdate can't be a static class because to be used as a yield instruction in Unity, a class needs to implement the IEnumerator interface. This interface requires instance methods such as MoveNext, Reset, and a property Current. A static class cannot provide these instance methods because it cannot be instantiated. So, the next best thing would be to instantiate a new one and cache it.

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

      @@git-amend Ah okay, makes sense, but let me rephrase. WaitForSeconds is difficult to re-use because the amount of time passed in changes we need new instances here, makes sense. But if the instances of WaitForFixedUpdate and WaitForEndOfFrame can be re-used across different coroutines I wonder why didn't unity already create instances of those automatically with sth. like initialize on load or similar (and make those accessable through a static class, the way you did).

    • @git-amend
      @git-amend  5 месяцев назад +1

      @@fleity That's a tough one, but given Unity's penchant for leaving things up to the developers, I think they would tell you that it is to provide the flexibility to control instantiation and lifecycle management explicitly. For example, you might want to add some kind of debug hook to the yield instruction instance (or it's usage). Of course, they've never really explained that one, so I'm just making a guess.

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

    How does this handle curves. Like if the walla had a minor bend to them, what if it was on a sphere, or just in general if that gravity well wasn't a perfect circle?

    • @git-amend
      @git-amend  4 месяца назад +1

      It's dependent on the center point to correctly determine where UP is. So, if you want to handle curves, then my suggestion is to use DOWN instead and make the normal of the curve the direction to align with, which will take a small extra calculation. With the outside of a sphere, you could just use the center point in that case but reverse the direction.

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

      @@git-amend I think you should consider adding a Möbius strip to your edge cases for character controllers that defy gravity. I think that's got to be the ultimate edge case (and will look awesome)

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

    Nice

  • @MrOmega-cz9yo
    @MrOmega-cz9yo 5 месяцев назад

    Hi, just wondering about a few things. most tutorials I've seen just parent an object to a platform, which you mention in the video. Any reason you didn't do that? Is the code more efficient, or just a choice? Also, to run around on a sphere, could you just reverse the gravity well up, or would there be more to it?

    • @uhhmir
      @uhhmir 5 месяцев назад +2

      First reason I could think of is that is that the player risks getting unloaded/destroyed along with its parent platform. It also copies the platform's rotation and scale to the player, which you might not want

    • @git-amend
      @git-amend  5 месяцев назад +1

      The main issue with the reparenting are the issues that @uhhmir mentioned, and beyond that, it may be more reusable and modular in that it can be adapted to various moving platforms and objects without worrying about the parent-child relationship.
      And, yes you can certainly do similar calculations to figure out the correct up direction on a globe - essentially the player's up direction will just need to be inverted.

    • @MrOmega-cz9yo
      @MrOmega-cz9yo 5 месяцев назад

      @@git-amend 👍

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

    nice

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

    can you do how to create a motion matching system tutorial

    • @git-amend
      @git-amend  3 месяца назад

      Well, I do love motion matching, but I think a video about how to make a system from scratch is beyond what I have time to make. Maybe a video explaining how to use an existing tool, or the principles of motion matching. I'll give it some thought.

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

      @@git-amend that wuld be fine

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

    Can you make a fps game I really need a good tutorial

    • @git-amend
      @git-amend  4 месяца назад +1

      Maybe one of these days, though to be honest I think not many people ask for that because there are so many videos about FPS on RUclips already. Is there something in particular about FPS that you think I could talk about that nobody else has covered before?

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

      @@git-amend As you said, there may be many resources on the internet, but I am really curious about your approach.

  • @forbiddenbox
    @forbiddenbox 5 месяцев назад +1

    SUNDAY

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

    16:24 the great for optimization that won't generates alote of garbage only create the instances once

    • @git-amend
      @git-amend  5 месяцев назад +1

      Yup, and I've now added that to the Utils library too for future use!

    • @-moristan109
      @-moristan109 5 месяцев назад +1

      @@git-amend great keep up the good work your content is the best out there