- Home /
How to attack with sword on Mouse Direction?
my game is a platform2D and i'm try make a Sword animetion play on same side the mouse
wanted to make the sword attack in the direction of the mouse on 2D Platform
Answer by Klarzahs · Feb 18, 2019 at 11:27 AM
Hi,
you can check the world position of your mouse with help of Camera.ScreenToWorldPoint(). You can then calculate the direction vector or offset and check whether it is greater zero (mouse is right) or not. If the mouse is left, you can simply flip your sprite renderer, which outputs your animation to the left.
You would probably have to adapt your collider as well though.
Your answer
Follow this Question
Related Questions
my 2d character is stucks at fall state 1 Answer
Multiple Cars not working 1 Answer
(2D) What is the best way to implement a run-and-shoot animation? 1 Answer
2D One, Two, Three Attack Combo 2 Answers
Distribute terrain in zones 3 Answers