Encapsulation movement Tavernkeeper_controller
This commit is contained in:
parent
82e1f258e3
commit
57088cfd12
1 changed files with 15 additions and 10 deletions
|
@ -79,16 +79,7 @@ public class Tavernkeeper_controller : MonoBehaviour
|
|||
hands = Input.GetAxis("Hand");
|
||||
|
||||
//Movement action
|
||||
Vector2 move = new Vector2(horizontal, vertical);
|
||||
//Update animation direction
|
||||
if(!Mathf.Approximately(move.x, 0.0f) || !Mathf.Approximately(move.y, 0.0f)) //Movement requested ?
|
||||
{
|
||||
lookDirection.Set(move.x, move.y); //== lookDirection=move
|
||||
lookDirection.Normalize();
|
||||
}
|
||||
animator.SetFloat("Look X", lookDirection.x);
|
||||
animator.SetFloat("Look Y", lookDirection.y);
|
||||
animator.SetFloat("Speed", move.magnitude);
|
||||
movement(new Vector2(horizontal, vertical));
|
||||
|
||||
//Actions delay
|
||||
if(isInteracting)
|
||||
|
@ -121,6 +112,20 @@ public class Tavernkeeper_controller : MonoBehaviour
|
|||
rigidbody2d.MovePosition(position); //Movement processed by the phyisc engine for Collision, etc.
|
||||
}
|
||||
|
||||
//Movement
|
||||
void movement(Vector2 move)
|
||||
{
|
||||
//Update animation direction
|
||||
if(!Mathf.Approximately(move.x, 0.0f) || !Mathf.Approximately(move.y, 0.0f)) //Movement requested ?
|
||||
{
|
||||
lookDirection.Set(move.x, move.y); //== lookDirection=move
|
||||
lookDirection.Normalize();
|
||||
}
|
||||
animator.SetFloat("Look X", lookDirection.x);
|
||||
animator.SetFloat("Look Y", lookDirection.y);
|
||||
animator.SetFloat("Speed", move.magnitude);
|
||||
}
|
||||
|
||||
//Handle action with hands ("left" or "right")
|
||||
void handAction(string hand)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue