Hi There! ^^ I found this little script on the internet that enables you to move a sprite with it’s assigned animations … Now i would like to change this to a Click-To-Move kinda thing to, instead of using the keyboard use the mouse … The problem is that before this i never have even touched the Animator and even less animated something xP … i mean i know how to do a Click to move … but Animation is completely new for me! xO
And i am on the need of some Pseudocode o “Way” to approach the problem … Any tips? =)
The Code:
void Update () {
Vector2 movement_vector = new Vector2(Input.GetAxisRaw("Horizontal"), Input.GetAxisRaw("Vertical"));
if (movement_vector != Vector2.zero) {
anim.SetBool ("iswalking", true);
anim.SetFloat("input_x", movement_vector.x);
anim.SetFloat("input_y", movement_vector.y);
} else {
anim.SetBool("iswalking", false);
}
rbody.MovePosition (rbody.position + movement_vector * Time.deltaTime);
}