I've been working on a top down rpg game with waves of enemies, and your videos are always a nice insight on how some of these mechanics can be done and I always enjoy them!
for the sword to swing in the mouse position mousePos = cam.ScreenToWorldPoint(Input.mousePosition); float angle = Mathf.Atan2(mousePos.y-transform.position.y, mousePos.x-transform.position.x) * Mathf.Rad2Deg - 90f; transform.localRotation = Quaternion.Euler(0, 0,angle); add this to playerinput
I have a question, in your demonstration, your sword swings in the direction of your mouse, when I used it, it would swing in the set direction. IS there any fix to this?
Everything here is perfect, but I have a question, in your demonstration, your sword swings in the direction of your mouse, when I used it, it would swing in the set direction. Can you tell me what I'm doing wrong please?
Hi Everyone! After much hair pulling and a helpful hidden reply in here: In order to fix the issue of the sword only swinging once, you must change the Update() function a little. **after the tutorial I had it as:* private void Update() { if(timeUntilMelee
make 2 int variables: "killcount" and "necessaryKillcount", set the first to 0 and the second to the number of enemies. Increase "killcount" by +1 on any enemy death. On update check if necessaryKillcount=killcount and if it does load the next scene
Hmm good point, the ideal solution would be to keep the sword at the end of the swing once finished, I'm sure you can set the animation to end and keep the position 🤔 I'll do a Google and write a comment if I find the solution
just posted this comment but I'll put here. In order to fix the issue of the sword only swinging once, you must change the Update() function a little. *after the tutorial I had it as: private void Update() { if(timeUntilMelee
ปีที่แล้ว
I loved the video, hello friend, can you guide me with something, I'm making a combo of attacks from a 2d game but the character has 8 directions and in each direction it has an animation that I want to turn into a combo of attacks when clicking release several attacks, you can guide me. I understand that it is with events in the animations. thank you so much
for anyone who wants it to follow the cursor just attach this piece of code to a script and attach the scrip to the parent of the weapon no i dont mean the player. Vector3 mousePos = Input.mousePosition; Vector3 screenPoint = Camera.main.WorldToScreenPoint(transform.position); Vector2 offset = new Vector2(mousePos.x - screenPoint.x, mousePos.y - screenPoint.y); float angle = Mathf.Atan2(offset.y, offset.x) * Mathf.Rad2Deg; angle -= 90; // Adjust the angle by 90 degrees transform.rotation = Quaternion.Euler(0, 0, angle);
Unfortunately since my game doesn't use the mouse I had to create a Blend Tree to properly rotate the animation depending on the direction the player is facing, like how you would with a Walking blend tree. Great video regardless, it was very helpful! :)
Hi! This is actually a request from your previous bow combat tutorial but I’m posting it here to make sure you see it! So I really need some help, I’m struggling to make it so that instead of the bow and arrow shooting at the direction of your mouse, it shoots *depending on the arrow key you press.* So that means pressing the up arrow key would make it to shoot up, the down arrow key would make it shoot down, Left arrow key would shoot it left and etc. *_Of course you’d have to consider making the bow rotate before the arrow shoots too._* Please would you be able to help me with the code for this? I’m very new to unity and I’ve been stuck doing this for days now
Sorry you're all experiencing this! If any of you want help fixing it feel free to jump on my discord server and create a post in the forum and I'll try help out!
I've been working on a top down rpg game with waves of enemies, and your videos are always a nice insight on how some of these mechanics can be done and I always enjoy them!
Woo! I'm happy to help! 💪
for the sword to swing in the mouse position
mousePos = cam.ScreenToWorldPoint(Input.mousePosition);
float angle = Mathf.Atan2(mousePos.y-transform.position.y, mousePos.x-transform.position.x) * Mathf.Rad2Deg - 90f;
transform.localRotation = Quaternion.Euler(0, 0,angle);
add this to playerinput
this also rotates the player.
@@obi_ladd1405 lock z rotation on your player character
You working on 2d top down series is helping me to work on some mechanics for little adventure I hopped into.
Awesome! I'd love to see it when you finish it!
I have a question, in your demonstration, your sword swings in the direction of your mouse, when I used it, it would swing in the set direction. IS there any fix to this?
Everything here is perfect, but I have a question, in your demonstration, your sword swings in the direction of your mouse, when I used it, it would swing in the set direction. Can you tell me what I'm doing wrong please?
Same thing here
PLEASE SOMEONE HELP HERE, IM HAVING THE SAME PROBLEM TOO!
mine can only attack on one side and i dont know how to fix it
Thanks for making my suggestion so quickly. Very impressive.
Hey if you ask, you get it!! Thanks for watching!
BRO HOW THE SWORD IS GOING WITH YOUR MOUSE POSITION
Good video, but you left out the part where the sword attack changes direction with the mouse.
how do you fix this?
hello, when I click the mouse, the sword swings from the same place. So it doesn't shake in the direction of the mouse. What is the reason?
I am having the exact same problem right now, did you manage to solve it? Or anyone?
I am also having the same problem did you figure out how to fix it?
same probleme here
same here
cause its based off player rotation, which he didnt include
Hi Everyone! After much hair pulling and a helpful hidden reply in here:
In order to fix the issue of the sword only swinging once, you must change the Update() function a little.
**after the tutorial I had it as:*
private void Update()
{
if(timeUntilMelee
Hey thank you so much i was lost Also for the actual code its anim not _animator
@@Cato202 lol sorry I changed the variable, but I'll change it back for this comment! :)
Hi, i have a problem with the sword animations when i attack it only goes halfway the animation
So have you consider to to work on in game shop system,like having npc to trade with or something similar.
Hell yeah! Do you mean like a Minecraft style trade?
@@MuddyWolf yeah, could think of like that
how can i make it so i get to next level when all enemies are killed
make 2 int variables: "killcount" and "necessaryKillcount", set the first to 0 and the second to the number of enemies. Increase "killcount" by +1 on any enemy death. On update check if necessaryKillcount=killcount and if it does load the next scene
Good video! I noticed the trail looks like it's still zipping back to the start position at the end of the swing. How do you prevent that?
Hmm good point, the ideal solution would be to keep the sword at the end of the swing once finished, I'm sure you can set the animation to end and keep the position 🤔 I'll do a Google and write a comment if I find the solution
I know this is late, but what I did to fix this was end the trail effect 1 frame before I stopped moving the sword in the animation.
when I set the melee speed to anything above 0 I'll be able to swing once before it stops working
same
just posted this comment but I'll put here.
In order to fix the issue of the sword only swinging once, you must change the Update() function a little.
*after the tutorial I had it as:
private void Update()
{
if(timeUntilMelee
I loved the video, hello friend, can you guide me with something, I'm making a combo of attacks from a 2d game but the character has 8 directions and in each direction it has an animation that I want to turn into a combo of attacks when clicking release several attacks, you can guide me. I understand that it is with events in the animations. thank you so much
for anyone who wants it to follow the cursor just attach this piece of code to a script and attach the scrip to the parent of the weapon no i dont mean the player.
Vector3 mousePos = Input.mousePosition;
Vector3 screenPoint = Camera.main.WorldToScreenPoint(transform.position);
Vector2 offset = new Vector2(mousePos.x - screenPoint.x, mousePos.y - screenPoint.y);
float angle = Mathf.Atan2(offset.y, offset.x) * Mathf.Rad2Deg;
angle -= 90; // Adjust the angle by 90 degrees
transform.rotation = Quaternion.Euler(0, 0, angle);
tried this, did not work
Unfortunately since my game doesn't use the mouse I had to create a Blend Tree to properly rotate the animation depending on the direction the player is facing, like how you would with a Walking blend tree. Great video regardless, it was very helpful! :)
Would you by any chance be able to explain how you accomplished this?
Hi! This is actually a request from your previous bow combat tutorial but I’m posting it here to make sure you see it!
So I really need some help, I’m struggling to make it so that instead of the bow and arrow shooting at the direction of your mouse, it shoots *depending on the arrow key you press.* So that means pressing the up arrow key would make it to shoot up, the down arrow key would make it shoot down, Left arrow key would shoot it left and etc.
*_Of course you’d have to consider making the bow rotate before the arrow shoots too._*
Please would you be able to help me with the code for this? I’m very new to unity and I’ve been stuck doing this for days now
idk what to do mine is only swinging once and that's it, i have to restart the game but it still does the same thing
I have the same problem...
@@Timo-gj5qq same here, did someone manage to work around it?
same
Sorry you're all experiencing this! If any of you want help fixing it feel free to jump on my discord server and create a post in the forum and I'll try help out!
@@MuddyWolf why cant you tell here?
this is an interesting idea but should framerate fall and you won't hit anyone
try putting the code to swing and detect damage in fixed update rather than update
Great vid
niceeeeee
11:12
bruh