Learn how to create 2D Top down Melee in Unity easily with a cool sword! // JOIN THE COMMUNITY DISCORD! / discord // PLAY MY DAMN GAME ALREADY? play.google.com/store/apps/de... // WEB DEV CHANNEL / tylerpotts
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 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);
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?
mine can only attack on one side and i dont know how to fix it
Год назад
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
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
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?
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
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
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
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!