Check out this Melee Combat System which is exactly what I used in Hyper Knights! 🌐 Have you found the videos Helpful and Valuable? ❤️ Support on Patreon www.patreon.com/unitycodemonkey or get the Game Bundle unitycodemonkey.com/gamebundle.php
Concise information as always. Someday could you cover how to code a combo system with precise inputs I.E. Marvel Vs. Capcom, Tekken, Skull Girls etc except in a top down format? Thanks for these CM! you're the best.
On 16:00 when I try to spawn enemies, the object being instantiated is null. Which I think is because of GameAssets.i.pfEnemy. I have the GameAssets script, do I put it on the enemy or spawner object? Both don't work for me when I assign the prefab to pfEnemy.
Make sure you're assigning the reference on the GameAssets prefab, not the object on the scene. Or assign it to the object on the scene but then also save the prefab Depending on the script order execution it might use the object in the scene or it might instantiate a new GameAssets prefab.
@@CodeMonkeyUnity It still seems to come up as null when assigning the reference with the prefab. I've tried putting the prefab in a "Resources" folder too but nothing seems to work.
Hi code monkey, great tutorial. I got a question. Why do we use this approach over using 2D colliders on the individual enemies? I understand this current game where there are lots of enemies this approach is objectively better but say for a game with 1v1 fights would it be better or worse to use 2D colliders instead?
Can you make a video on weapon system as part of player attack? Maybe how equipment can be accounted for into the player attack and animation system? For example, melee attack verse ranged attack versed caster magic? One uses a sword, the other a bow, and the last magic which may or may not have a weapon equiped?
Depends a lot on how you set things up, you need to break that problem into smaller pieces, first handle the animations, then handle the sprites, then handle unit stats and so on. ruclips.net/video/isAmoM3RPEI/видео.html
hey man nice videos tyou have there. I have a question: is there any isometric real time arpg and mouse movement controlled (diablo-clone) with freeflow combat mechanics? (like shadow of war , assassins creed etc) Im looking for nice and many animations, counter attacks and that smooth cinematic/acrobatic feeling . ty in advance.
Hi, how do i go about making the character face the attack direction after an attack instead of snapping back to its last moveDirection. I've been stuck at it for hours and can't seem to figure it out. Thanks :)
That depends heavily on what animation system you're using, but you would just basically store a Vector3 for the lastAttackDirection and default to that animation while not moving.
hey CM I have one more question why did you return an Enemy when creating an enemy . I found out that it is also possible to create an object without retuning anything in some cases , can you please explain it to me it would be very helpful for me. thanks And also why did you instantiate a transform and not a gameobject ??
In order to attack towards the mouse So if you click above and to the right of the character it will find hte closest enemy in that direction, if you leave the player in the same position and click under and to the left it will find another enemy in that direction
@@CodeMonkeyUnity Thanks I got it.👍 But How transform.position + mouseDirection leads to mouse direction ? Addition of a position vector and a direction vector leads to the direction vector , but how??
This is the only video on the internet I can find that explains how to targeted melee attacks, yet, if you follow this tutorial, you'd have to write an entire library of other utilities and animation scripts. Each one with leads back to previous videos. At this point, trying to get my character to have targeted melee becomes useless because I might as well just pretend my game is your game. Solution: is there a simpler way of rotation an animation from the animator?
The logic for finding the target is what matters, calculating the direction and identifying nearby objects, that logic can work with any animation system you want.
Well, you could take this video as an inspiration and try to implement it in your game, the key is the ability to learn from ideas and make your own solution.
If you have a vector to where the enemy is looking at and you have the player position you can calculate the Dot product and if its < 0 then the player is behind
Hey there, I am rather new to unity and was hoping to find a better way(then with timers) to let the attack animation finish before returning to idle. I don't want to manage timers for every attack(if possible). Appreciate your guidance thanks!
You could just make a proper timer class with some simple exposed functions to start a timer and get a callback. Something like: public void StartTimer(float time, Action onTimerElapsed);
Yeah a Terraria like game is something I was actively working towards but I haven't covered many sidescrolling systems yet so I had to postpone that project. I was preparing for a normal Top Down Survival Crafting game but then got caught up with the DOTS update so haven't been back to it. There's lots of cool stuff I want to make, just not enough time to do them all!
Isnt it bad practice to just allow the player to spam the mouse to attack, wouldnt it be better to have a timer to limit the number of attacks, like attacks per second or some such mechanism.
Depends on what type of game you're making. If it's meant to be like Dark Souls then you should let the animation play fully, if it's meant to be fast paced you can let the player attack at every click.
I'm Thinking This Camera Is Cool But But Most Of The People Wants To Create Complete Platformer / metroidvania but unfortunately most of the tutorials are incomplete I wish you can make some on udemy or on RUclips
Hey Code konkey I really need your help I want to make a combat system that makes you go in combat mode when you click a button so like there are two modes one for combat other for pasif actions Please Help ı really need this
@@CodeMonkeyUnity Yes! THANK YOU but can I define the same thing for the player and not with AI instead with a input button I am fairly new to unity and you are the best at teaching
Usually I speed up the sections where I'm just typing and not talking in order to keep the video flowing. But when I write and talk at the same time yeah that's my normal typing speed. Been writing code for 20 years!
I love how I did all this research on how to do 2D targeting with a mouse, implement it and then fucking Code Monkey comes along with a tutorial explaining it all in exactly the same way :( he's as bad as Brackey's, he's even doing the same maths to make the raycast accurate.
@@457Deniz457 Yes exactly lmao, I don't hold it against them, this is how technology and coding works but it is such a piss take when a video for my problem gets uploaded moments later. I think it was actually a couple of days ago I dealt with the issue and had to find some obscure unity forum post on google of course.
Check out this Melee Combat System which is exactly what I used in Hyper Knights!
🌐 Have you found the videos Helpful and Valuable?
❤️ Support on Patreon www.patreon.com/unitycodemonkey or get the Game Bundle unitycodemonkey.com/gamebundle.php
Concise information as always. Someday could you cover how to code a combo system with precise inputs I.E. Marvel Vs. Capcom, Tekken, Skull Girls etc except in a top down format? Thanks for these CM! you're the best.
You're so underrated. I love your tutorials, thank you so much.
ty for the tips for each video, very helpful
Love the video!
So nice ! Thanks ! :)
On 16:00 when I try to spawn enemies, the object being instantiated is null. Which I think is because of GameAssets.i.pfEnemy. I have the GameAssets script, do I put it on the enemy or spawner object? Both don't work for me when I assign the prefab to pfEnemy.
Make sure you're assigning the reference on the GameAssets prefab, not the object on the scene. Or assign it to the object on the scene but then also save the prefab
Depending on the script order execution it might use the object in the scene or it might instantiate a new GameAssets prefab.
@@CodeMonkeyUnity It still seems to come up as null when assigning the reference with the prefab. I've tried putting the prefab in a "Resources" folder too but nothing seems to work.
Hi code monkey, great tutorial. I got a question. Why do we use this approach over using 2D colliders on the individual enemies? I understand this current game where there are lots of enemies this approach is objectively better but say for a game with 1v1 fights would it be better or worse to use 2D colliders instead?
Sure you can place a collider in the attack position and look for what it hits, or even better just do Physics2D.CircleCast();
@@CodeMonkeyUnity cool. Appreciate the reply
Pretty new to this, just getting started - does this use the new input system from Unity? or the old one?
It uses the old input system but you can easily convert it, the melee logic is the same
are your animations basically 8 cardinal direction?
or are they procedural animations?
They are 8 animations, made using my mesh animation system unitycodemonkey.com/video.php?v=11c9rWRotJ8
Can you please make a tutorial for this Character Base animation thing?
Yes I covered it here ruclips.net/video/11c9rWRotJ8/видео.html
Can you make a video on weapon system as part of player attack? Maybe how equipment can be accounted for into the player attack and animation system? For example, melee attack verse ranged attack versed caster magic? One uses a sword, the other a bow, and the last magic which may or may not have a weapon equiped?
Depends a lot on how you set things up, you need to break that problem into smaller pieces, first handle the animations, then handle the sprites, then handle unit stats and so on.
ruclips.net/video/isAmoM3RPEI/видео.html
hey man nice videos tyou have there.
I have a question: is there any isometric real time arpg and mouse movement controlled (diablo-clone) with freeflow combat mechanics? (like shadow of war , assassins creed etc) Im looking for nice and many animations, counter attacks and that smooth cinematic/acrobatic feeling . ty in advance.
Hi, how do i go about making the character face the attack direction after an attack instead of snapping back to its last moveDirection. I've been stuck at it for hours and can't seem to figure it out. Thanks :)
That depends heavily on what animation system you're using, but you would just basically store a Vector3 for the lastAttackDirection and default to that animation while not moving.
hey CM I have one more question why did you return an Enemy when creating an enemy . I found out that it is also possible to create an object without retuning anything in some cases , can you please explain it to me it would be very helpful for me. thanks And also why did you instantiate a transform and not a gameobject ??
CodeMonkey I have one Question why did you take attackPosition = (transform.position + mouseDirection ) ? mathematical explanation .
In order to attack towards the mouse
So if you click above and to the right of the character it will find hte closest enemy in that direction, if you leave the player in the same position and click under and to the left it will find another enemy in that direction
@@CodeMonkeyUnity Thanks I got it.👍 But How transform.position + mouseDirection leads to mouse direction ? Addition of a position vector and a direction vector leads to the direction vector , but how??
This is the only video on the internet I can find that explains how to targeted melee attacks, yet, if you follow this tutorial, you'd have to write an entire library of other utilities and animation scripts. Each one with leads back to previous videos. At this point, trying to get my character to have targeted melee becomes useless because I might as well just pretend my game is your game. Solution: is there a simpler way of rotation an animation from the animator?
The logic for finding the target is what matters, calculating the direction and identifying nearby objects, that logic can work with any animation system you want.
Well, you could take this video as an inspiration and try to implement it in your game, the key is the ability to learn from ideas and make your own solution.
What if you wanted to scroll the combat text on a panel?
Code MonKey!! you are always the best, will you consider making a top down shooter game like Archero??
I'm not familiar with that one but I did do a Top Down Shooter a long time ago ruclips.net/video/Eyx3EfqqfMw/видео.html
Do you have a rear attack? I mean extra damage if you hit the enemy from behind?
If you have a vector to where the enemy is looking at and you have the player position you can calculate the Dot product and if its < 0 then the player is behind
@@CodeMonkeyUnity I did your turn based battle system. Does it have that in the scripts?
Does anyone know the video where he shows how the attack is animated?
MY animation system is based on dynamic meshes unitycodemonkey.com/video.php?v=11c9rWRotJ8
@@CodeMonkeyUnity ahh i was hoping that wasnt the case. Cant wrap my head around that one for some reason. Ill give it another go!
Hey there, I am rather new to unity and was hoping to find a better way(then with timers) to let the attack animation finish before returning to idle. I don't want to manage timers for every attack(if possible). Appreciate your guidance thanks!
You could just make a proper timer class with some simple exposed functions to start a timer and get a callback.
Something like: public void StartTimer(float time, Action onTimerElapsed);
Hey can you make armor tutorial
Hey code monkey what about a 2d Minecraft game like terraria with simple inventory and crafting system. A small series would be great
As it turns out he's already done a crafting system tutorial.
ruclips.net/video/LmQ6U3YkHHk/видео.html
Violet twd hey dude 😊👋🏻
Yeah a Terraria like game is something I was actively working towards but I haven't covered many sidescrolling systems yet so I had to postpone that project.
I was preparing for a normal Top Down Survival Crafting game but then got caught up with the DOTS update so haven't been back to it.
There's lots of cool stuff I want to make, just not enough time to do them all!
You know a game dev doesn't fuck around when he codes in every single mechanic in his games.
Isnt it bad practice to just allow the player to spam the mouse to attack, wouldnt it be better to have a timer to limit the number of attacks, like attacks per second or some such mechanism.
Depends on what type of game you're making. If it's meant to be like Dark Souls then you should let the animation play fully, if it's meant to be fast paced you can let the player attack at every click.
I'm Thinking This Camera Is Cool But But Most Of The People Wants To Create Complete Platformer / metroidvania but unfortunately most of the tutorials are incomplete I wish you can make some on udemy or on RUclips
how do you make a player jump in 2D top-down game?
Depends on how you want to implement it since there's no "natural" way to display that
@@CodeMonkeyUnity can you make a video of how to do it? Also I am unable to reach you for some questions I had. Do you provide any tutoring?
Tutorial on your ‘animation system’?
It's based on dynamic meshes, I covered it here ruclips.net/video/11c9rWRotJ8/видео.html
Hi
do these codes work on mobile or only windows and linux?
The only difference between Desktop and Mobile is the Input method changing from Keyboard to Touch. Everything else is the same
Code Monkey Hi
So i should copy your toturial and it will work?
And what is the input method?
Hey Code konkey I really need your help I want to make a combat system that makes you go in combat mode when you click a button so like there are two modes one for combat other for pasif actions Please Help ı really need this
Sounds like you need to define a State machine. I covered something similar in the Enemy AI video ruclips.net/video/db0KWYaWfeM/видео.html
@@CodeMonkeyUnity Yes! THANK YOU but can I define the same thing for the player and not with AI instead with a input button I am fairly new to unity and you are the best at teaching
@@OutBoy12123 Sure, instead of switching states automatically you do it when the player presses a button
@@CodeMonkeyUnity Thank you so much You are the best out there about this topic also my game dev idle
A quick question When I go to Instantiate(GameAssets
That class was made here ruclips.net/video/7GcEW6uwO8E/видео.html
What is your camera size ?
About 70, the number itself doesn't matter, it's all relative to the size of your objects.
Can you make your player jump ?
Sure ruclips.net/video/ptvK4Fp5vRY/видео.html
Your videos are so awesome, but I have to know: are you really typing in real time?
Usually I speed up the sections where I'm just typing and not talking in order to keep the video flowing. But when I write and talk at the same time yeah that's my normal typing speed. Been writing code for 20 years!
The codemonkey utils have a lot of errors
I dont know what to do
What errors?
@@CodeMonkeyUnity Camera errors mostly in util folders
@@CodeMonkeyUnity Also I would love a video
explaining the codmonkey utils
I prefer learning without using utils and packages
@@nontasng8068 Are you talking about the Utils or project files?
The project files uses Cinemachine, but the Utils themselves don't need anything.
I love how I did all this research on how to do 2D targeting with a mouse, implement it and then fucking Code Monkey comes along with a tutorial explaining it all in exactly the same way :( he's as bad as Brackey's, he's even doing the same maths to make the raycast accurate.
Lel.. so ur mad bcs u "wasted" time or bcs of that others can do the same thing in a fraction of the time u had invested?^^
It's very important to develop the skill of doing your own research so all the time you spent wasn't wasted!
@@CodeMonkeyUnity Yes ! :)
Thats why I said "wasted" :P
@@457Deniz457 Yes exactly lmao, I don't hold it against them, this is how technology and coding works but it is such a piss take when a video for my problem gets uploaded moments later. I think it was actually a couple of days ago I dealt with the issue and had to find some obscure unity forum post on google of course.
@@lethn2929 Well I feel you.
I also have to struggle thing where I know in 1-2 years everone can quick google it ... xD