level 1
金杰死了
楼主
这是我的代码
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class NewBehaviourScript : MonoBehaviour
{
public float speed = 3;
Animator anim;
Vector3 move;
// Start is called before the first frame update
void Start()
{
anim = GetComponent<Animator>();
}
// Update is called once per frame
void Update()
{
float x = Input.GetAxis("Horizontal");
float z = Input.GetAxis("Vertical");
Vector3 move = new Vector3(x, 0, z);
transform.LookAt(transform.position + new Vector3(x, 0, z));
transform.position += new Vector3(x, 0, z) * speed * Time.deltaTime;
UpdateAnim();
}
void UpdateAnim()
{
anim.SetFloat("speed", move.magnitude);
}
}
2023年02月16日 11点02分
1
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class NewBehaviourScript : MonoBehaviour
{
public float speed = 3;
Animator anim;
Vector3 move;
// Start is called before the first frame update
void Start()
{
anim = GetComponent<Animator>();
}
// Update is called once per frame
void Update()
{
float x = Input.GetAxis("Horizontal");
float z = Input.GetAxis("Vertical");
Vector3 move = new Vector3(x, 0, z);
transform.LookAt(transform.position + new Vector3(x, 0, z));
transform.position += new Vector3(x, 0, z) * speed * Time.deltaTime;
UpdateAnim();
}
void UpdateAnim()
{
anim.SetFloat("speed", move.magnitude);
}
}