Let's make a Modular Character Controller where we can build Modules (Movement System, AI, Pathfinding) and compose them to make our Character Controller! 🌍 Go to admix.in/ and Start Earning Revenue in under 24 hours! 👍 Using the tool helps support the channel!
@arsenbabaev10224 жыл бұрын
is it good idea to use it in RTS ? i feel like i need around 10 modules for all behaviors moving units garher res. atk.
@CodeMonkeyUnity4 жыл бұрын
@@arsenbabaev1022 It would be very useful in an RTS. Your Gatherers and Soldiers would share the same Movement and Animation modules with a different Logic module.
@nxd28774 жыл бұрын
i will be glade if the next tut about trigger particle system with 2d trigger by code
@Norbingel4 жыл бұрын
Showing the end result of what the tutorial will accomplish right at the beginning of the video so people know whether it's something they want is something every tutorial should do. That alone would get me subscribed if I weren't already.
@CCV3344 жыл бұрын
I love the format of his videos they jump into the tutorial right away, no wasted time!
@mcgeufer4 жыл бұрын
I came for the tut but stayed for the add. That's actually something I was looking for a long time. Integrating adds in a game instead of disturbing the players expieirence all the time.
@TripleCreeper33 жыл бұрын
i bought 2 courses and saw around 20 tutorials to find finally one that is oriented to changing movement, weapons, etc... Much thanks!!!
@raghulponnusamy90344 жыл бұрын
you are awesome .currently I'm separating visual and core logic using events that made code very easy to use. Thanks for all the videos.
@mehmedcavas30694 жыл бұрын
Ohh yes. The most important thing of solid code. This is by far the best tutorial for clean code and also shows how to add multiple scripts on one go and how to interact with them 😊😊
@tiagodarkpeasant4 жыл бұрын
finally the part i wanted to learn, making simple scripts is easy, using all of them in the same object not so much
@oyaguni9613 жыл бұрын
Not going to lie, I love you for introducing me to interfaces. Thank you SO very much for your invaluable content!
@justinwhite27254 жыл бұрын
Thanks for sharing admix. I know it’s probably sponsored but it’s highly relevant. Unfortunately most of my games are fantasy and it doesn’t seem appropriate, but I love the idea.
@deadly_artist4 жыл бұрын
Share your opinion on that, but I bet it would be funny for players if they were to find ads in cities, towns, sci-fi ships or dungeons or whatever, especially where it doesn't fit at all - as long as it isn't overbearing
@CodeMonkeyUnity4 жыл бұрын
Yeah it's a sponsor but the product is excellent, if I did free games I would certainly use it. Banner ads are always awful.
@paulblart73783 жыл бұрын
Super helpful video! I'm making a defense game and I want a lot of my scripts (target finding, attacking, AI logic, etc.) to be usable by towers, units, and enemies, so a modular system is crucial. That way, I can easily create different behaviors by swapping out components. Thanks a lot!
@janmarcbaniqued76124 жыл бұрын
This is amazing!!! I didn't know we can use interfaces like that. This changes so so much thank you!
@eierschaedl Жыл бұрын
i love the sound of your keyboard. so satisfying.
@Carter_Moody4 жыл бұрын
If you experience that Movement is relative to distance clicked (faster if mouse farther away) then check to see that the Z axis in all components is the same or 0 for 2d. Also check prefabs for this
@nerdact59203 жыл бұрын
Im relearning c# right now and i feel like i understand the importance of this so much better now. Great video which i couldnt appreciate before the way i do now. And I'll probably appreciate it at some later stage even more :D
@CodeMonkeyUnity3 жыл бұрын
I'm glad you found the video helpful!
@user-hz4tc2pf3x4 жыл бұрын
Could you make a video about stuff that isn't considered when talking about tutorials? (E.g.: resolution, build bugs, optimizing code, pixel perfect camera (seriously who knows how that works?), polishing and just more advanced and further-into-development tutorials)
@FICHEKK4 жыл бұрын
Amazing and very helpful video! Please do more of these "good-design" and "architecture" videos!
@LoopyWolf5 ай бұрын
Presented very logically
@oldcat17904 жыл бұрын
Interfaces video sounds interesting.
@extremeliving592 Жыл бұрын
You sir, are a genius...
@Carter_Moody4 жыл бұрын
Add This line if (Vector3.Distance(movePosition, transform.position) < .0001f) moveDir = Vector3.zero; // Stop moving when near to avoid sprites shaking when finish moving. This was not included in the video and instead I found it in the game files on his website.
@zamilamin36463 жыл бұрын
where to add this code
@Carter_Moody3 жыл бұрын
@@zamilamin3646 I'm sorry it's been so long, I forget
@TheBigHeinousAnus3 жыл бұрын
@@zamilamin3646 it's in the MovePosition class... also for anyone else reading this, if you still get shaking after adding this line, make sure your Rigidbody2D has the correct gravity settings configured. I added that component after adding the scripts and spent a few hours being really confused as to why my RTS units were still acting like they had too much coffee...
@supapaw11 ай бұрын
6:52 actually it has two purposes: to move the rigidbody AND play the animation :)
@filipgawlik32594 жыл бұрын
Please, make a video about interfaces. By the way - do You recommend using Scriptable Objects?
@CodeMonkeyUnity4 жыл бұрын
Sure, they can be an insanely useful tool. A lot of official unity things, (like HDRP, URP, Shader Graph) use Scriptable Objects to organize their data.
@tiagodarkpeasant4 жыл бұрын
i use for example to make characters, so i change one object and that changes both the controlable character and any interface related to the character, like for example changing the hp in the scriptable object so it affects the character selection interface and the actual hp of the unity i can also have different prefab paths that i put int the scriptable object so depending of the scene the same character could be diferent gameobjects, like overworld object, turn battle object, water level object i am making a pokemon like rpg, and in the scriptable object i list all the skills the species can learn, while saving the moves they know in another class that i use for save games
@arcday42814 жыл бұрын
You're cool! No doubt you will have more and more subscribers and support, the main thing is not to stop feeding us lessons ))) . I only understood half of it, but it was enough to watch with interest...
@KalponicGames4 жыл бұрын
this tutorial is amazing :). You really like top-down games. 90% tutorials you have are top-down
@CodeMonkeyUnity4 жыл бұрын
Yup I'm a big fan of Top Down 2D and with that perspective I can showcase pretty much any system possible!
@KalponicGames4 жыл бұрын
@@CodeMonkeyUnity is email a good way to contact you? The one on youtube?
@LoopyWolf6 ай бұрын
All this code, and a great tutorial.. Support!
@CodeMonkeyUnity6 ай бұрын
Thanks for the super thanks! I'm glad you found the video helpful!
@LoopyWolf6 ай бұрын
@@CodeMonkeyUnity While I have your attention, quick question.. Is the code provided for this video what is used in the RTS tutorial? ps I sent you a donation. I hope you got it!
@CodeMonkeyUnity6 ай бұрын
hmm it's been quite a long time since I made this and that video so I'm not 100% sure but since they came out at roughly the same time I think so. For that RTS tutorial I focused just on the selecting characters logic, so the movement is super simple.
@tigransahakyan28404 жыл бұрын
Great as always Also it would be really great to see how did you make you animation system in details cause there is so many things in animation system.
@kruth66633 жыл бұрын
This is what I'm looking for. Thanks!
@personanongrata44194 жыл бұрын
Hey codemonkey - do you have any plans on covering the stuff in between this and your past A* pathfinding video? I've been following along and am a little lost because it seems like there are a lot of changes from the PathNode/Grid video and this one, with binary trees and all the other pathfinding scripts. thanks!
@mehmedcavas30694 жыл бұрын
can you also show us how you combined it with your animation script? a simple one with walk, idle and attack would be enough
@kerduslegend26446 ай бұрын
this is a great tutorial. although i have a several question, for example "should you reparate animator logic with a movement logic?"
@CodeMonkeyUnity6 ай бұрын
Personally I like to keep logic and visuals as separate as possible, so normally I do separate the movement logic from the animator logic. Although it also depends on the complexity of your project, if it's something simple you can just keep them together. But on complex things I make a separate class that just handles the animation parameters.
@MaGiStReall4 жыл бұрын
Love your videos, keep it up! Btw, will there be any multiplayer tutorials?
@CodeMonkeyUnity4 жыл бұрын
Yeah I've been meaning to look into the state of Unity DOTS NetCode, hopefully soon!
@mohameddabbour69614 жыл бұрын
Yes! please make video about interfaces
@digitalfortress12084 жыл бұрын
Dude you are awesome. This is good stuff.
@danielvillalba44573 жыл бұрын
Hi, great video, yes I would like to see a video dedicated to interfaces and how to explore their benefits in Unity, I use them a lot in web development in order to enable composition and decoupled designs, I have been using them in Unity for a couple of years during my exploration but I’m sure you have lots of cool implementations.
@MrAmix24 жыл бұрын
You focused on manually changing the scripts, but is it possible to do it during runtime? For example is enemy sees player it switches AI script to chase him and after a while returns back to default state, by enabling / disabling components. Will it work? Great video :)
@CodeMonkeyUnity4 жыл бұрын
Yup, that's pretty much what I did when I made the Top Down Shooter game kzbin.info/www/bejne/e6rbZHicptaZg9k When the enemies get spawned they are static, essentially they have their logic and move components disabled while the spawn animation finishes.
@benjaminsnow50954 жыл бұрын
Absolute mad lad! You are truly epic!
@pabloandresherreracantilla91774 жыл бұрын
Not sure if I'm doing something wrong. When I assign the MoveTransformVelocity script to my player, it starts colliding with other objects. Any ideas?
@papatomicjusz3 жыл бұрын
Any progress on that issue?
@utkugokalp31794 жыл бұрын
Great video as always! But why did you chose to make an IMovementVelocity instead of an abstract class? Because I would probably choose to create an abstract class in order to reduce code coupling since both of the classes have very little different code. Other interfaces make sense since the actual codes implemented are very different from one another but I really don't understand the purpose of using interfaces for very little code changes, it just seems like code coupling to me.
@CodeMonkeyUnity4 жыл бұрын
Usually an interface is meant for exposing certain behaviour whereas an abstract class is meant to represent a more complete object, that's why interfaces are public and have no fields. I don't want MovementVelocity to be an object, I want it to represent a specific behaviour. Interfaces also let you have multiple implemented in one class, so if you had a lot of modules you could create more complex modules that group more simple behaviour.
@utkugokalp31794 жыл бұрын
@@CodeMonkeyUnity Thanks :) I've been trying to understand the difference since like forever :P
@gdk8704 жыл бұрын
@@CodeMonkeyUnity This is the best argument read yet for using an Interface vs. Abstract class. Good job.
@washynator4 жыл бұрын
Correct me if I'm wrong, but you are not supposed to use GetComponent inside of Update, right?
@CodeMonkeyUnity4 жыл бұрын
Yes correct, doing GetComponent on every Update is not good for performance. However in this case I did it that way so that I could demo swapping out the modules in real time, if I had cached them, like you should do in a proper game, it would give me a NullReferenceException when changing the module.
@washynator4 жыл бұрын
@@CodeMonkeyUnity Yeah, well that does make sense. Awesome video still! Keep up the great work!
@markedforstrike4 жыл бұрын
@@CodeMonkeyUnity maybe we can use variable and check if component available or not. Also once I saw smth with instances, not sure about it, but script was called via ScriptName.Instance.MethodName(); P.S. Hello from Russia, Mr. Worldwide UPD Sorry, it was just public static
@magictimm40904 жыл бұрын
@@CodeMonkeyUnity Have you heard about this? since 4.6 GetComponent in Update is not a problem for performance. www.reddit.com/r/Unity3D/comments/4xptnk/a_c_generic_class_that_wraps_getcomponent_caching/d6hj3iy/
@techbytefrontier4 жыл бұрын
Great video, please make one about your animation system.. sync animation in unity sometimes can be very hard for me..
@CodeMonkeyUnity4 жыл бұрын
It's based on dynamically modifying meshes kzbin.info/www/bejne/Z2LGaqWNh9SngJo
@zekiozdemir4203 жыл бұрын
Thanks for making these videos
@kken87664 жыл бұрын
Please make a video about interface!!!~~~
@CodeMonkeyUnity4 жыл бұрын
A function signature is the definition of the return type and the parameters. void TestFunction(int i); The signature for this function is it returns void and takes an int parameter. Interfaces being a contract means you HAVE to implement those functions, if you don't you get a compiler error.
@kken87664 жыл бұрын
@@CodeMonkeyUnity
@keetee-ei3er Жыл бұрын
Awesom, thansk! How is that you dont need to add IMoveVelocity interface script to player object inspector and it still works?
@CodeMonkeyUnity Жыл бұрын
You don't attach an interface directly to a game object, you attach some MonoBehaviour that implements that interface
@keetee-ei3er Жыл бұрын
@@CodeMonkeyUnity Awesome, thanks
@dodo5045 Жыл бұрын
why cant u have 2 scripts using the same interface with 1 disabled, u have to remove the other component completely?
@kylemedina51123 жыл бұрын
Notes: 11:16 Using Interface script for the ability to switch between scripts(that inherit from the Interface class)
@notrue4u2 жыл бұрын
7:28 isn't GetComponent in update methods a bad way to get a reference to the script you want? it is said to be expensive and not recommended, i think you should also mention that in your tutorials.
@CodeMonkeyUnity2 жыл бұрын
Yes, it is only used in the demo to showcase hotswapping the components while the game is running. In a proper game you would cache the component.
@grachamoncha Жыл бұрын
At 15:37 you cut away then you have a system called GridPathfindingSystem at the top. Where did you get this? How can I get it? A quick Google doesn't yield any definitive results.
@CodeMonkeyUnity Жыл бұрын
That's my own pathfinding system, it's not a Unity built-in thing so that's why you can't find it. I covered the A* Pathfinding algorithm in detail here unitycodemonkey.com/video.php?v=alU04hvz6L4
@keetee-ei3er Жыл бұрын
float moveX = 0f; float moveY = 0f; if (Input.GetKey(KeyCode.W)) moveY = +1f; if (Input.GetKey(KeyCode.S)) moveY = -1f; if (Input.GetKey(KeyCode.A)) moveX = -1f; if (Input.GetKey(KeyCode.D)) moveX = +1f; So does moveX and moveY automatically returns back to zero after either one W,S,A,D key is released (GetKey=false)? Thanks, appreciate this channel and everyone involved!
@ghiancarlostan87302 жыл бұрын
is this a good way to create a weapon system? like i should create different scripts per unique weapons based on their attack patterns?
@umairmalik64804 жыл бұрын
Please make a video on interface also
@nikolasxyinidis75144 жыл бұрын
Thank you soooo much this is very helpful
@ericf.22674 жыл бұрын
Would there be any benefits/drawbacks to doing something similar through events, instead of interfaces? I would assume you could make a similar modular character system, but using different architecture (maybe you could address that in an interface video, which I would be totally for). Keep up the good work man!
@CodeMonkeyUnity4 жыл бұрын
What do you mean through events? Events just broadcast that something happened, they dont "hold" logic. I guess maybe you could have some base classes and different modules would extend those base classes in different ways and fire off events when something happened? That would be a very strange messy architecture
@ericf.22674 жыл бұрын
In a lot of your videos you use events to also pass along information using delegates and eventhandlers. In this video you use the interface to set up a "contract" about what information gets passed to an agreed upon method (like vectors or positions). I imagine you could have a class set up events that could send along information to subscribing components, which would still "hold" the logic. So you could set up an input class that would pass information to subscribers when keys were pressed or when a mouse was clicked (with the subscribing components handling that even information any way they wanted) Hope that makes more sense!
@quinclarke23312 жыл бұрын
Hi i' having a problem with the pathfinding on click, as i followed the grid video generic grid video and also A* pathfinding video. However in none of them is a method called instance or GetRouteWithShortCuts created and i'm confused as too where they've come from. If anyone knows where they're from or if i can replace them with something else as i'm a bit lost right now. Thank you!
@CodeMonkeyUnity2 жыл бұрын
The pathfinding that I covered in that video is the simplest thing possible, in most videos where I use pathfinding I'm using a more advanced version of the algorithm. That function simply makes shortcuts where the path is unobstructed, so instead of the unit zig zagging when moving diagonally it just goes straight until it finds a wall
@llamagame8817 Жыл бұрын
@@CodeMonkeyUnity I’m guessing “the more advanced version” is covered in your pathfinding with DOTS(insane speed) tutorial? Thanks
@dannykay46494 жыл бұрын
Please do a dedicated video on interfaces!
@Michal0054 жыл бұрын
Can you make video on storage or chest compatible with your inventory???
@CodeMonkeyUnity4 жыл бұрын
The Inventory is just a class so it can live wherever you want, you can use it as a UI Element or open/close a window by touching a Chest. The inventory itself doesn't really need to change.
@MB-eq9ew3 жыл бұрын
Using get component in update , is same with getting in start but way more optimization problem right ?
@CodeMonkeyUnity3 жыл бұрын
Yes I only did it that way for the video to demonstrate the system while hot swapping. For a final game you would only do it once on Start
@FyresGames2 жыл бұрын
Great idea. Could it be used in a level system? I mean activating a script when you reach a specific level? Would it be a good idea to put all the modular scripts onto the player and use a level up script to enable/disable them depending the player level?
@john23773 жыл бұрын
Is it good if we use the GetComponent right inside the Update method and also to declare variables? Doesn't it affect the performance of the game?
@CodeMonkeyUnity3 жыл бұрын
Yes I did that only for demo purposes so I could hot swap the components in runtime, in your own games you should definitely cache the values and not do GetComponent on every Update
@mohokhachai Жыл бұрын
Professional tutorial
@jimmyfitzsimmons7170 Жыл бұрын
At 12:11 I've done the exact setup as you did but with the MoveTransformPosition Script activate my player can't pass through the wall. But if I remove the rigidbody or turned it into a Kinematic Rigidbody he is able to go through the wall. But I didn't see you touch the rigidbody component at all so what am I missing ?
@CodeMonkeyUnity Жыл бұрын
That behaviour is sort of dependent on your framerate. Basically on every Update the transform is being forced inside the wall, but then on the FixedUpdate the Rigidbody tries to move the object away from the wall. So you're probably not missing anything, just running the game at a lower framerate which makes it more "difficult" for the Update code to force the transform inside the wall
@hidingdissident Жыл бұрын
@@CodeMonkeyUnity whats your framerate? I am running this with 160 fps and I am bouncing off the wall when using the MoveTransformPosition script.
@andylockhart2574 жыл бұрын
Yes please on Interfaces!!
@gfulpakwuli37993 жыл бұрын
Really awesome, I am using similar system, of course at runtime time all this components would be enabled/disabled instead of added/removed. I am curious about the light around your character. Is it a light, or simply a sprite with transparency, what is an optimized way to do it?
@CodeMonkeyUnity3 жыл бұрын
Yup it is a 2D light, I never tried pushing the 2D Lighting system to it's limits but I never had issues with it.
@thedevquest76764 жыл бұрын
PLEASE! make a video on interfaces! I'm really struggling to find a good source to learn good coding principles. It's come to my attention that all if not almost all unity novice tutorials I've done over the last 3 weeks and about 70 + hours of my time have been teaching my very BAD code practices. ie. not implementing SOLID principles, HUGE player classes and no composition or interfaces. I've looked high and low for a good 2D top down or 2d platformer tutorial that implements all these good practices while teaching C#. I can't seem to find it anywhere so If you could cover them even separately that would be amazing!
@CodeMonkeyUnity4 жыл бұрын
I just published a video on interfaces today! kzbin.info/www/bejne/g4uyo3qOoJmLfKs
@magictimm40904 жыл бұрын
Why "public const int WALL_WEIGHT = 56000;" in the GridPathfinding class? Must i reduce the 56000 if I reduce the nodeSize ? The Pathfinding in my Project has some problems on edges of objects.
@Michal0054 жыл бұрын
How to change this scripts by code???
@GamernetsLP2 жыл бұрын
I am using the MoveTransformVelocity script that you make here together with the mouse position direct movement and the character jitters very hard once they reach their target location. How can I fix that?
@CodeMonkeyUnity2 жыл бұрын
Sounds like you need to define some stopping distance and stop it when it gets close, it will never 100% reach the perfect mathematical correct position.
@cbr97313 жыл бұрын
I have the problem in direct movement with the mouse, where the transform component does not fit into the mouse position at the moment originating as a vibration.
@Bartek-6772 Жыл бұрын
How you get grid for pathfinding? You use GridPathfinding.Instance is it automatic calculating grid or you just defined it manually? (i am only interested in method not how script works)
@CodeMonkeyUnity Жыл бұрын
It's using A* Pathfinding which I covered here unitycodemonkey.com/video.php?v=alU04hvz6L4
@Bartek-6772 Жыл бұрын
@@CodeMonkeyUnity i know that but how do you set not walkable area? In video that you linked you set the grid at runtime. But in this video it looks like automatic process. You just use GridPathfinding.Instance... without setting the grid before start. Do you have script that sets it manually or you just didn't show setting grid in video?
@supergalaxysam3 жыл бұрын
Your tutorial is great; It's very easy to follow along and straight to the point. I know this is meant more for a 2D controller, but I tried to follow it to create a modular controller for 3D games. What would I use in replacement for the code presented within the "PlayerMovementKeys.CS" script to get "W" and "S" to move forward and backward in a 3D space? I am also running into a compiling error with the "PlayerMovementMouse.CS" script because the game is unable to recognize "(UtilsClass.GetMouseWorldPosition());". Unity version is 2020.2.6f1 with VisualStudio 2019.
@CodeMonkeyUnity3 жыл бұрын
The easiest thing is just to swap Y movement for Z movement. UtilsClass is part of my utilities, here's how you get the world position kzbin.info/www/bejne/Zpu3gX6waMyUatk
@waltuh084 жыл бұрын
you are the best thank you
@victrolaface4 жыл бұрын
If I wanted to separate the player data into a scriptable object i.e. speed, health, strength etc. What is a good approach adhering to modularity? I assume make a InitializeData component that serializes the scriptable object, then each subsequent component, i.e. HealthComponent sets it's field "health" to the InitializeData component's scriptable object's health value. My concern is the usage of get/require component, performance, and coupling of data. Is it better to have a public field in each component for the scriptable object or is my approach above more efficient? Appreciate your feedback.
@CodeMonkeyUnity4 жыл бұрын
Having a central script holding all your stats would be a good approach. It would make your scripts tighly coupled with your data script but that's not necessarily a problem. Achieving perfect modularity and code decoupling is a good goal to have but don't let that blind you from your primary goal of actually making your game, sometimes more modularity will actually increase complexity.
@Semaj0z4 жыл бұрын
Why don't u use getaxis for the player wasd movement
@Cultofcosmossubscriber3 жыл бұрын
Actual video starts at 0:00
@danielcorzo74983 жыл бұрын
Hi, I have some questions: Just how modular should I make a character (or anything)? I mean, if I wanted to create something like a character in a RPG (say Skyrim), will I end with dozens of different scripts attached to the character by taking this approach? Also, if I wanted to create my own components (like a Rigidbody), how modular should I make them? Thank you
@CodeMonkeyUnity3 жыл бұрын
That depends on your specific scenario. Modularity can be a huge help but it can also be bad, it's just another tool. Make a quick prototype and see which method works best.
@nbdy2964 жыл бұрын
with the direct mouse movement, my character stutters around the target postion instead of just stopping... any clues why ?
@asemon0074 жыл бұрын
I'm suffering the same problem
@nbdy2964 жыл бұрын
@@asemon007 I worked it out eventually after watching the rest of the vid. At 15:45 when he shows the pathfinding movement he uses a threshold to determine when to stop movement (line 26). I used that in the direct movement too and it fixed it.
@asemon0074 жыл бұрын
@@nbdy296 Thanks man!
@CodeMonkeyUnity4 жыл бұрын
Yes, depending on how fast your unit moves you need to adjust the distance for it to stop moving.
@theashbot4097 Жыл бұрын
with the mouse input and move position it makes the character go past the target then I get the glitchy movement where the unit never hits the way point. how did not not get it?
@CodeMonkeyUnity Жыл бұрын
Depends on how fast you move it and how tiny is your reachedPositionDistance. IF you move too fast and you have too tiny distance it might constnatly jump back and forth because it never quite gets there
@johngalt2002 жыл бұрын
What are the shortcuts from GetPathRouteWithShortcuts?
@CodeMonkeyUnity2 жыл бұрын
It creates paths with direct waypoints instead of stair-like paths, moving diagonal for a long distance instead of up-right-up-right-up-right
@kiss_fish4 жыл бұрын
Im a bit confused - how does the pathfinding work in this project - all your pathfinding tutorials work with grids but here you just have objects in a scene? Or do you have a tutorial covering this?
@CodeMonkeyUnity4 жыл бұрын
There is a Pathfinding grid being used, it's just not visible.
@kiss_fish4 жыл бұрын
But how did you make the nodes around the wall unwalkable
@keelanbowker-obrien22224 жыл бұрын
Instead of grabbing rigidbody for move velocity could you grab game object so that move velocity could interact with things like lights?
@CodeMonkeyUnity4 жыл бұрын
The MoveTransformVelocity script moves the transform directly without any Rigidbody
@byeileft8944 жыл бұрын
Can u do these coding but with good 3d models cause I want to try to make a pokemon based game
@CodeMonkeyUnity4 жыл бұрын
Pretty much all the code works in 3D and there are only some small changes needed. Instead of using Rigidbody2D use Rigidbody. Instead of SpriteRenderer use MeshRenderer
@andrewshandle4 жыл бұрын
This is great.
@MalikenGD4 жыл бұрын
Is the modularity shown here good for ECS (not necessarily DOTS)? Is this a great example of subbing out components or systems?
@CodeMonkeyUnity4 жыл бұрын
Hmm yes in the sense that ECS is all about Components so you can have a MoveSimple IComponentData and a MovePathfinding IComponentData However I don't think ECS works with interfaces since that requires type conversion.
@lordzombieboy5 ай бұрын
Tutorial start: 5:40
@MatthewChowns4 жыл бұрын
Could this sort of modular approach be used with DoTs? ie. swapping between two different systems, or enabling/disabling certain features while testing?
@CodeMonkeyUnity4 жыл бұрын
Yup, DOTS is already super efficient at only running Systems if there are Entities that match the Query.
@r1pfake5214 жыл бұрын
Ad for a Ad plugin, Adception.
@adeled88332 жыл бұрын
It didnt go through the wall, my player rotated when touched walls like crazy for some reason with the first (rb) method
@AstraGamesStudios2 жыл бұрын
Hey @CodeMonkey ! i was wondering if this code will still work (and with your RTS click and command units video) in top-down 3d? Just like the game you make from the Unity co-op project.... the one with the pigs. 🐷 Thanks!
@CodeMonkeyUnity2 жыл бұрын
Sure, all this is doing is moving to a position, that position can be on the XZ plane or XY, getting the mouse position is the big difference unitycodemonkey.com/video.php?v=0jTPKz3ga4w
@AstraGamesStudios2 жыл бұрын
@@CodeMonkeyUnity sweet! thanks! btw, if you did a video on a top-down 3D RTS game that would be really cool! Have a good one!
@AstraGamesStudios2 жыл бұрын
@@CodeMonkeyUnity sweet! thanks!
@SanderVerveer6 ай бұрын
Would it be posible to post me "Character_Base " content, stuck on the part that is untill now not in the video, with kind regards. Sander
@CodeMonkeyUnity6 ай бұрын
That class is just responsible for rendering/animating the character, you can use whatever animator controller you want, it's not directly related to making a modular character system
@lucasgiffuni62674 жыл бұрын
Hi, can you do a tutorial of melee attack system with the sword?
@CodeMonkeyUnity4 жыл бұрын
Yeah I covered it here kzbin.info/www/bejne/d4nOkqSNaKpshas
@FergoniusYeet4 жыл бұрын
Is there a way to implement this pathfinding with an isometric tilemap?
@CodeMonkeyUnity4 жыл бұрын
You can have isometric visuals while keeping a flat logic grid. Just need to do calculations when converting positions into grid positions.
@tonyclx4 жыл бұрын
@Code Monkey I used it in Unity 2018 and 2019 still getting this error CS0234: The type or namespace name 'Universal' does not exist in the namespace 'UnityEngine.Rendering' I am a beginner. I really appreciate your help. All I am trying is to run the exact project you made. I have added nothing to it..thanks
@CodeMonkeyUnity4 жыл бұрын
You need to install the Universal RP from the package manager
@MrREALball4 жыл бұрын
Can you make the same thing using dots? Im still not used to thinking in dots terms, so maybe its extremly easy to do, but I cant think of a good way to do so.
@CodeMonkeyUnity4 жыл бұрын
DOTS is already component based so the core logic works the same however I don't think DOTS supports Interfaces so thats the one key difference. But you can already have lots of systems that each do their own behaviour depending on the component on the entity.
@SebyGamerZROZ4 жыл бұрын
Nice work ! ✓
@Palutena6184 жыл бұрын
Great video, as always! I've come across an issue that didn't pop up in your video: When trying to make a character or any object move via the mouseinput, they move towards the point but then overshoot it due to the movespeed jumping back and forth around the destination spot. If I reduce the movespeed, the issue is less pronounced but it still does that for quite a few loops. Also, if I don't normalize the moveDir vector3, there's no jittering at the destination but then the movement is not linear and goes way too fast. Am I missing something here? It's a simple issue but I can't figure out how to solve it in this setup.
@CodeMonkeyUnity4 жыл бұрын
Usually you do a distance check to test if it reached the position, and if your character is teleporting then it sounds like its moving more each frame than the distance you're testing for. Either increase the amount that you're testing or test the distance before and after moving, if it's further after than before then you've reached your destination.
@ronnid88374 жыл бұрын
Hey Code Monkey, how would you implement a state machine pattern into a design like this? Say for example, the player should move differently when in inAir_State or in onGround_State? Thanks and nice tutorial as always!
@CodeMonkeyUnity4 жыл бұрын
I covered a basic state machine here kzbin.info/www/bejne/mpOTfIqPlryZm68 However in your case if you just want to handle movement with a different speed then a simple boolean isGrounded would be a better approach
@ronnid88374 жыл бұрын
@@CodeMonkeyUnity Thanks, will have a look at that. It's a bit more complex I guess.. I got a bird and he should be able to: - walk on the ground(GroundState) - jump from ground(InAirState) - glide while InAir(GlideState) And all states should treat input differently. I'm stuck on how to implement this.. Have you got an idea how to deal with this?
@Ashley-xb1dz4 жыл бұрын
@@ronnid8837 It seems like you would just trigger different states, walk (arrow keys) jump (space bar) double jump/glide (press space bar twice) ...
@AdidasDoge2 жыл бұрын
The move postiion direct usually overshots the target position, how can I solve this?
@CodeMonkeyUnity2 жыл бұрын
You can check the current and the next position, do a distance check to the target, if the next position is further away then the current, just set the next position to be the target position.
@AdidasDoge2 жыл бұрын
@@CodeMonkeyUnity Sorry, I am a beginner, could you please provide an example of the code?
@TheMapaSoft4 жыл бұрын
Hello CodeMonkey... I love your video about different part of game development, but here with this one I disagree completely. In Unity, the rule of thumb is "Less Monobehaviours, the performance better". For a simple Character controller, well, why not, but when you want to share some functionalities for ennemies, it is where it become difficult. Being in the game dev for almost 20 years, I suggest that you use ScriptableObject more than MBehaviours, You could have one component, let name it Pawn, and that pawn reference scriptable objects for each "Context" you want the character to be. For example, one context for the movement on the Ground, another for the movement in Air, another for Dash, another for Sword Attack, and so forth. The good this with this approach, is that you can share contexts between player and enemies at a very low cost. I should say also, that configuring Scriptable Objects is far more convenient than monobehaviours.
@CodeMonkeyUnity4 жыл бұрын
This modular approach does let you share logic between player and enemies. You can have the enemies and the player both using the same Sword or Projectile script. Not sure what you mean by cost. Running through a list of ScriptableObjects and running the logic or doing it through MonoBehaviours will pretty much end up the same.
@TheMapaSoft4 жыл бұрын
@@CodeMonkeyUnity Hello, by cost I mean cpu wise. Updating a ScriptableObject instead of a MonoBhv is far cheaper. Having worked for Unity (worked on Timeline feature) I can tell you that even thought, your MB do not have an update or other "magic function", Unity will try to call them every frame. This is not the case for a ScriptaleObject, beside the OnEnable and OnDisable method.
@TheMapaSoft4 жыл бұрын
@Erick Luis Souza ScriptableObject is just a class where you can serialize data (what we called an Asset). A mono behaviour cannot be saved in a file itself(or in an Asset) but a MonoBehaviour can take a ScriptableObject as an input and use the data to behave according to the data contained in the ScriptableObject. We call that "Data-Driven" approach, versus the code-driven approach where you have to change the code, recompile and see the result. I think that @CodeMonkey has a tutorial about ScriptableObject.
@philiphanhurst26554 жыл бұрын
It's probably not the best idea to use GetComponent() in Update, since from what I've heard it can be pretty heavy.
@CodeMonkeyUnity4 жыл бұрын
Yup true, I only did it that way to showcase hotswapping the modules in the demo. In a final game you would choose what modules you wanted and do GetComponent on Awake.
@gamespark34263 жыл бұрын
when I use GridPathFinding VS cannot find it and said that "Error CS0246 The type or namespace name "gridpathfindingsystem" could not be found"
@CodeMonkeyUnity3 жыл бұрын
That's not a built-in Unity class, it's the Pathfinding that I built in a previous video kzbin.info/www/bejne/l524YWeeq99pgpY
@gamespark34263 жыл бұрын
@@CodeMonkeyUnity understood. Thanks bro.
@kushovu4 жыл бұрын
Where is the link to the video that u told at 5:22, the Animation system, i cant find it
@CodeMonkeyUnity4 жыл бұрын
It's this one: kzbin.info/www/bejne/Z2LGaqWNh9SngJo