level 1
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class sou : MonoBehaviour
{
private CharacterController _Sparrow;
private Animation _animator;
// Start is called before the first frame update
void Start()
{
CharacterController _Sparrow = GetComponent<CharacterController>();
_animator = GetComponent<Animation>();
}
// Update is called once per frame
void Update()
{
float horizontal = Input.GetAxis("horizontal ");
float vertical = Input.GetAxis("Vertical");
Vector3 dir = new Vector3(x: horizontal, y: 0, z: vertical);
if (dir != Vector3.zero)
{
transform.rotation = Quaternion.LookRotation(dir);
_animator.SetBool(name: "iswalk", KeyValue: true);
transform.Translate(translation: Vector3.forward * 2 * Time.deltaTime);
}
else
{
_animator.SetBool(name: "iswalk", value: false);
}
}
}

2023年06月08日 04点06分
1
using System.Collections.Generic;
using UnityEngine;
public class sou : MonoBehaviour
{
private CharacterController _Sparrow;
private Animation _animator;
// Start is called before the first frame update
void Start()
{
CharacterController _Sparrow = GetComponent<CharacterController>();
_animator = GetComponent<Animation>();
}
// Update is called once per frame
void Update()
{
float horizontal = Input.GetAxis("horizontal ");
float vertical = Input.GetAxis("Vertical");
Vector3 dir = new Vector3(x: horizontal, y: 0, z: vertical);
if (dir != Vector3.zero)
{
transform.rotation = Quaternion.LookRotation(dir);
_animator.SetBool(name: "iswalk", KeyValue: true);
transform.Translate(translation: Vector3.forward * 2 * Time.deltaTime);
}
else
{
_animator.SetBool(name: "iswalk", value: false);
}
}
}
