forked from diegousdz/Lightship-AR
-
Notifications
You must be signed in to change notification settings - Fork 0
/
animationManager.cs
52 lines (37 loc) · 1.03 KB
/
animationManager.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class animationManager : MonoBehaviour
{
public Animator anim;
public GameObject anchorAvatar;
public float movementSpeed = 5.0f;
public float rotationSpeed = 200.0f;
public float x;
public float y;
public void Update()
{
x = Input.GetAxis("Horizontal");
y = Input.GetAxis("Vertical");
var tempRot = new Vector3(0,x * Time.deltaTime * rotationSpeed, 0);
anchorAvatar.transform.Rotate(tempRot);
var tempTrans = new Vector3(0,0,y * Time.deltaTime * movementSpeed);
anchorAvatar.transform.Translate(tempTrans);
if(y > 0.2){
anim.Play("walking1");
}
if(y < 0.1){
if(y>=0){
anim.Play("idle");
}
}
if(y >= 0){
if(y<=0.1){
anim.Play("idle");
}
}
if(y <= -0.1){
anim.Play("WalkingBackward");
}
}
}