James Makes Games
James Makes Games
  • Видео 9
  • Просмотров 483 308
Unity Hacks: C# Extension Methods
Learn how you can use C# extension methods to add your own methods to existing Unity classes.
SUBSCRIBE
Subscribe for more game dev tips and tutorials: bit.ly/3edJUA5
Просмотров: 4 043

Видео

Using Interfaces in Unity Effectively | Unity Clean Code
Просмотров 59 тыс.2 года назад
Learn how using C# interfaces can help keep your unity code clean and allow you to add new mechanics to your game even faster SUBSCRIBE Subscribe for more game dev tips and tutorials: bit.ly/3edJUA5 CODE Grenade: pastebin.com/WcZ2ug6d ExplosiveBarrel: pastebin.com/jLi30XJ4 DestructibleCover: pastebin.com/6g3AFJzZ EnemyTarget: pastebin.com/7m50eC8p FirstPersonController: pastebin.com/ieR6uD5a IT...
This Game Dev Tip Saved Me 137 HOURS!
Просмотров 3,9 тыс.2 года назад
Learn how this game dev tip can help you manage and prioritise new game ideas so you can actually finish your dream game project. Whether it's your dream game or a game jam, this method will help you finish it on time! SUBSCRIBE Subscribe for more game dev tips and tutorials: bit.ly/3edJUA5
Escape Nesting Hell - Do This Instead
Просмотров 267 тыс.2 года назад
Learn how to improve your if statements in Unity to make them cleaner, more readable and easier to maintain using guard clauses. SUBSCRIBE Subscribe for more game dev tips and tutorials: bit.ly/3edJUA5
Your Game Needs TWO Names (Here's Why)
Просмотров 8 тыс.2 года назад
Learn why your game needs two names and how this can help speed up your development of your game. SUBSCRIBE Subscribe for more game dev tips and tutorials: bit.ly/3edJUA5
Night Vision the RIGHT Way | Unity Tutorial
Просмотров 16 тыс.2 года назад
Learn how to create a night vision effect in Unity without shaders that even works in complete darkness, just like Splinter Cell. SUBSCRIBE Subscribe for more game dev tips and tutorials: bit.ly/3edJUA5 CODE NightVisionController: pastebin.com/HySM4fBr
Pause in Unity WITHOUT Timescale
Просмотров 120 тыс.3 года назад
Learn how to pause your game in Unity in less than 2 minutes without setting timescale using events. This allows you to still use time-based logic in pause menus and background systems and can even be extended to work for cutscenes, loading screens and game over screens. TIMESTAMPS 00:00 Intro 00:05 Game State Manager 00:51 Hook up Player Movement 01:13 Pause and Resume 01:33 Why? Next Steps? 0...
Try This Game Dev Productivity HACK!
Просмотров 3,3 тыс.3 года назад
An essential game dev tip that will help you start your indie game development journey, push through when you feel stuck and most importantly, maintain the motivation to finish your indie game. TIMESTAMPS 00:00 Intro 00:05 The Problem 00:35 The Solution 01:29 Why This Works? 02:14 Outro SUBSCRIBE Subscribe for more game dev tips and tutorials: bit.ly/3edJUA5

Комментарии

  • @Mannavard88
    @Mannavard88 4 дня назад

    Man, u've create nice content, sad to see that channel is abandoned :(

  • @Mannavard88
    @Mannavard88 4 дня назад

    Thank you, very clean and useful explanation with examples

  • @moeingharib6857
    @moeingharib6857 9 дней назад

    this was the most comprehensive, simple and useful video I've seen in months..

    • @JamesMakesGamesYT
      @JamesMakesGamesYT 8 дней назад

      Thanks for the kind words, glad this video was helpful

  • @PedroBoris-ws6ks
    @PedroBoris-ws6ks Месяц назад

    Thank you so much it's so easy and help me a lot of in my project

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

      No problem! What project are you working on?

    • @PedroBoris-ws6ks
      @PedroBoris-ws6ks Месяц назад

      @@JamesMakesGamesYT horror game

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

      Oh yeah, the night vision will work really well with that! Best of luck!

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

    Depth of field will ruin performance

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

      Yeah, that’s a good point some post processing effects can lower performance. It can be something you use sparingly, like for cutscenes, or you can try to improve the performance elsewhere. Thanks for the comment!

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

    Try to guess "Demeter" Stardew Valley lol

  • @omar-0082
    @omar-0082 Месяц назад

    thanks you so much but i have a dumb question, can I add multiple functions into one interface or i must avoid that? Anyway tanks you very much !

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

    what if i have other post effects, will it turn those off too

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

      I think if you create a separate post processing profile for general effects and night vision, then they wont affect each other

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

      @@JamesMakesGamesYT oaky thanks

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

    The main mistake of the author of this video, as well as others like it, is that they consider the state machine as a tool for setting the state. But one should use a state machine as a tool for determining (!) the state of an object. Yes, there is a tricky definition of a state machine, but who reads all this... That is, describe all the states of an object, determine them and, based on the state of the object, execute methods. More complex projects may have more than 1 state machine. The second mistake many authors make is to copy the animator’s unity ideology. They argue that an object must change from one state to another. For example, from waiting only to running. Apparently they forgot about the wonderful animator's hell, which everyone has already said 1000 times. Modern animation programs don't have any states. You can call any animation from code. Just like in Unity, but we love states - arrows, entanglements....? And finally. Multiple returns in code. We moved away from multiple ifs to returns. And to empty return. And, according to the idea, return should return something - that’s what it was invented for, but no, we use it as an analogue for stopping the execution of a method. Also multiple returns are not very good architecturally. Since we have 1 entry point into the method and 10 exit points from it. There are other problems with this approach, but I probably won’t describe them...

  • @Ryöken17
    @Ryöken17 2 месяца назад

    It's cool in a way, but there is a priority, can't you have an if and a print depending on wich one triggers ?

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

    Thank you for this tutorial, it was really helpful! Though this makes me wonder: is the interface only accessible to the script that defined it or is it accessible from any script? And if it isn't, how can I for example make an object damageable by different objects (and not just the player)?

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

      You can get an interface from any script using the GetComponent<T>() method. The method is accessible on all game objects so you can call it on a collider if you raycast or collide with an object for example

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

      @@JamesMakesGamesYT Thanks!

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

    Amazing explanation

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

    what if you have a special attack for example when ur sprinting and jumping? how would you fit that into this structure

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

      Good question. I think for something like this scenario, the ordering of guard clauses would be the solution. So the first guard clause would check if both sprinting and jumping are true then after that have two separate guard clauses for sprinting and jumping. Hope that makes sense

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

    The animation not working if there is math in them is very true! And I'm one of them who use time scale, i created.. was it if statement to check if the time scale is above 0 then the math is done and if less it will stop calculating so the animations wont brake. definitely i crate a small test to see this out !

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

    wow i was almost going crazy trying to understand from other source. thank you so much

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

    I can't begin to tell you how much this has helped me, Thank you.

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

    So, with mine, It somewhat works. The keybind works, etc etc. shows green in editor, HOWEVER, When actually playing on that map, pressing N doesn't make the camera lens go green, it just brightens up the world a little. Any reason on why? nvm I broke it even more, upgraded to urp and it doesn't even show anything now.

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

    that was really usefull and clear , im just not sure .. where do you write the Interface - > public Interface Idamageable { void damage(amount) }

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

      You can create an interface in a new file like you would creating a new script

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

    Great Video!

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

    Perfectly explained fast and clear

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

      Better than offical unity video

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

    Thank you! This tutorial really helped me, and I appreciated how quick you went through with this one. I really didn't want to use Timescale as it felt like I wouldn't have any control.

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

    This saved my life

  • @JAKEAVALON-rg8xm
    @JAKEAVALON-rg8xm 6 месяцев назад

    why you need to write all of them when you can just write in 1?

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

    this video explains interfaces better than my college classes lol

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

    GetComponent can retrieve Interfaces? I thought it could only grab actual components, makes the name misleading.

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

      Initially, it did only retrieve components, specifically anything that inherited from UnityEngine.Component, hence the name. But in 2014, the method was updated to take better advantage of C#'s generics, and now it can retrieve any type that is, inherits from, or implements the target type. The name has remained the same for backwards compatibility reasons.

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

    this is good but how do i check if the collision is not in play, because I'm using a boolean in my code to check if the enemy is grounded or not using this interface method

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

    I will just use events in tandem with time scale. Even more control and efficiency.

  • @Johan-rm6ec
    @Johan-rm6ec 8 месяцев назад

    Thank you for not using the word C.O.N.T.R.A.C.T. once!!!!

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

      he did tho twice XD at 2:30

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

      I actually like the contract analogy but I think it gets misused. When you write up a contract with someone, for example a plumber, the contract doesn’t say “you will be a plumber” it says “you will do the following plumbing tasks” Again it comes back to the “what you are” vs “what you do” example from the video

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

    To the nay sayers in comments, this is how you are supposed to pause. Dont be lazy and sloppy take your time to make your game right. Events are efficient and performant and this removes any bugs with pausing from the various other lazy methods.

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

    This might seem like a stupid question, but what are you doing in this line? EnemyTarget target = hitInfo.collider.GetCompoment<EnemyTarget>(); is this a way to create an instance of a variable from another class? What is is required to do this? I understand the rat cast part I am actually only confused about the declaration of target

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

      i think he is caching the target object to make his life easier

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

    I could do this with sub classes. Interfaces just makes things a little bit longer. Then why are they exist? I never felt like I really need interfaces.

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

      He goes over that in the video. You're only able to inherit from one class. What if you want to give your class more functionality after the you you make the subclass to work with another system you already have in place?

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

      @@erikberg2893 I changed my mind thank you

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

    damn such a great explanaition. definetely deserves a sub. thank you so much man :D

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

    Thank you, I am currently making something where the player can move in 2d, but needs to interact with stuff and need something that allows them to interact with a button without knowing what the interactable object does

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

    i doubt u can come up with a dev name for Portal or Portal 2 lol

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

      Tricky one! How about Hermes - God of travelling?

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

    "find a script that will be affected by pausing" - like almost all of them? Do I need to put all this amount of code in every script that is affected by pause?

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

    You are actually teaching here how to create a singleton and use delegates and events. This is not a tutorial of "better pausing technique" in Unity.

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

    Doesn't work, tried to make it work with many and many changes but nothing

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

    I never fully understood interfaces and this perfectly explains it. Thanks.

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

    This is incredibly helpful. Thank you!

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

    code link cant open :(

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

    i cant reach code links

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

    this was an amazing explanation, i already used and fully understood interfaces, but this helps increase the Modularity of code , which decreases time to add new features, and removes dependency within code , which can then further be boosted by the observer method

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

    I can't express how much this 4 minute video has helped me. Thanks so much!

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

    Thank you. Implemented... wow.. so much easier than the jumble i was working with. Great, consise, easy to follow tuturial.. and exaclty what i wanted and how i wanted it to work. Damage ammount on the thing that actually does the damage... then health on the thing that actually looses health... so simple.. no of these weird incorrectly placed and refenenced tangles

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

    I thought I was watching a tutorial Little did I know it was actually a speedrun.

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

    But watch out, often clean code is very slow code, sometimes even many times slower.

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

    That is a good start. I would also add that all the if should be extracted to a guard method that returns a tuple (bool isAttackable, string message) = CanAttack(..); Methods must only do one thing. This one is doing two: 1. checking to see if you can attack, then if you can then attack. This makes the code much more testable.

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

    Better yet, use chain of responsability. A list of classes implementing the same interface, each one checking for a specific condition. The method walks the list of classes before performing the action and returns early if any of them fail. That way you just need to add a new entry to the class list when adding a new restriction, leaving the original method untouched.

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

      This is interesting. The question I have around this would be how is each condition class getting the data to do the checks?

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

    i understand it now, you are a beast

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

    I'm still not sure if I need to be using interfaces or a base class on my current project