- Home /
Question by
Mutumii · Mar 20 at 10:19 PM ·
2d animation
Change Animation Position
How do I change the position of my attack animation? It should be around my player based on where the mouse position is.
This code makes the attack animation rotate on its z axis on my player but not on a fixed circle distance.
Vector3 diffrence = Camera.main.ScreenToWorldPoint(Input.mousePosition) - transform.position;
float rotZ = Mathf.Atan2(diffrence.y, diffrence.x) * Mathf.Rad2Deg;
transform.rotation = Quaternion.Euler(0f, 0f, rotZ + offset);
if (mouseClick1)
{
ChangeAnimationState(WEAPON_SWING1);
}
else
{
ChangeAnimationState(FILLER);
}

unityquestion.png
(1.3 kB)
Comment
Your answer
Follow this Question
Related Questions
Basic Movement on 2D (C#) 1 Answer
The sprite editor won't let me slice 7 Answers
Problem with Scrip for sprites 1 Answer
2d Animation and Colliders 0 Answers