Skip to content

Instantly share code, notes, and snippets.

@WakkyFree
Created April 17, 2021 04:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save WakkyFree/bdf6754161c05372f2cf87b8a2d851ce to your computer and use it in GitHub Desktop.
Save WakkyFree/bdf6754161c05372f2cf87b8a2d851ce to your computer and use it in GitHub Desktop.
control bear walk and stop
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