Created
April 17, 2021 04:51
-
-
Save WakkyFree/bdf6754161c05372f2cf87b8a2d851ce to your computer and use it in GitHub Desktop.
control bear walk and stop
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
public class BearWalk : MonoBehaviour | |
{ | |
private Animator bearAnm; | |
// Start is called before the first frame update | |
void Start() | |
{ | |
bearAnm = GetComponent<Animator>(); | |
} | |
// Update is called once per frame | |
void Update() | |
{ | |
if(Input.GetKey("up")) | |
{ | |
transform.position += transform.forward * 0.01f; | |
bearAnm.SetBool("isWalk", true); | |
} | |
else | |
{ | |
bearAnm.SetBool("isWalk", false); | |
} | |
if (Input.GetKey("right")) | |
{ | |
transform.Rotate(0,2,0); | |
} | |
if (Input.GetKey("left")) | |
{ | |
transform.Rotate(0, -2, 0); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment