- Home /
how to make a character Animation walk,idle,Attack and death ? its should do all these things 2.5 Isometric way.
please anyone can help me with this thing. I want it like A.I (walk,attack and death).
private void Update()
{
//depending on origin
if (GameController.Instance.GetCurrentActiveScene() == Constants.LevelScene.Empire)
{
Move();
}
}
private void Move()
{
switch (_person.DirectionOfPerson)
{
case Constants.MovementDirections.North:
transform.position += new Vector3(-0.8f * _person.MoveSpeed * Time.deltaTime, 0.5f * _person.MoveSpeed * Time.deltaTime, 0);
_personAnimation.SetInteger("Direction", (int)Constants.MovementDirections.North);
break;
case Constants.MovementDirections.East:
transform.position += new Vector3(0.8f * _person.MoveSpeed * Time.deltaTime, 0.5f * _person.MoveSpeed * Time.deltaTime, 0);
_personAnimation.SetInteger("Direction", (int)Constants.MovementDirections.East);
break;
case Constants.MovementDirections.South:
transform.position += new Vector3(0.8f * _person.MoveSpeed * Time.deltaTime, -0.5f * _person.MoveSpeed * Time.deltaTime, 0);
_personAnimation.SetInteger("Direction", (int)Constants.MovementDirections.South);
break;
case Constants.MovementDirections.West:
transform.position += new Vector3(-0.8f * _person.MoveSpeed * Time.deltaTime, -0.5f * _person.MoveSpeed * Time.deltaTime, 0);
_personAnimation.SetInteger("Direction", (int)Constants.MovementDirections.West);
break;
}
}
private void OnTriggerEnter2D(Collider2D collision)
{
CurrentDirection = _person.DirectionOfPerson;
if (GameController.Instance.GetCurrentActiveScene() == Constants.LevelScene.MyEmpire)
{
if (collision.gameObject.CompareTag("Troop")) // to detect the troop collision to another troop
{
changeAntiClockwiseDirection();
}
else if (collision.gameObject.CompareTag("Wall")) //to check the wall the detection
{
changeToOppositeDirection();
}
}
}
public void changeAntiClockwiseDirection()
{
if (CurrentDirection == Constants.MovementDirections.North)
{
_person.DirectionOfPerson = Constants.MovementDirections.West;
}
else if (CurrentDirection == Constants.MovementDirections.South)
{
_person.DirectionOfPerson = Constants.MovementDirections.East;
}
else if (CurrentDirection == Constants.MovementDirections.East)
{
_person.DirectionOfPerson = Constants.MovementDirections.North;
}
else if (CurrentDirection == Constants.MovementDirections.West)
{
_person.DirectionOfPerson = Constants.MovementDirections.South;
}
}
public void changeClockwiseDirection()
{
if (CurrentDirection == Constants.MovementDirections.North)
{
_person.DirectionOfPerson = Constants.MovementDirections.East;
}
else if (CurrentDirection == Constants.MovementDirections.East)
{
_person.DirectionOfPerson = Constants.MovementDirections.South;
}
else if (CurrentDirection == Constants.MovementDirections.South)
{
_person.DirectionOfPerson = Constants.MovementDirections.West;
}
else if (CurrentDirection == Constants.MovementDirections.West)
{
_person.DirectionOfPerson = Constants.MovementDirections.North;
}
else
{
Debug.Log("Unknown Direction in clockwise direction method");
}
}
It's not how Unity Answers works.
There are lot of tutorials on youtube. Go and watch some. Try it yourself. And then if you still don't succeed come here, show us your code/screenshots of what you tried and we will help you with an advice or even a piece of code.
code has been posted as you said. i have tried many tutorials. it was not working. thanks a lot man. i have created 3 animator for all direction like for idle , attack , death. different animator different situation. is that right what i did?
Your answer
Follow this Question
Related Questions
how to add a walking animation when character is moving? 3 Answers
Combining two animations? 2 Answers
character death - In transitions settings, where is ‘can transition to self’? 3 Answers
Help with attacking, and death animation. Unity 5 javascript 1 Answer
Importing character + animations, and blend/scripting - looking for an up to date tutorial? 0 Answers