实在是解决不了了,求大神帮忙
unity3d吧
全部回复
仅看楼主
level 1
LightningMQ95 楼主
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
level 7
1
2023年06月09日 07点06分 4
level 5
你连问题都没说,没有前因后果地贴一段代码,别人怎么帮你[喷]
2023年06月09日 08点06分 5
level 1
dir.sqrMagnitude<0.01f
2023年06月09日 10点06分 6
level 6
_animator
这个前面声明了没,我外行[滑稽]我只看到Animation_animator
2023年06月09日 11点06分 7
level 8
去问GPT,我现在都问GPT,比百度管用多了
2023年06月09日 12点06分 8
level 3
你声明的是animation不是animator,Horizontal "H"大写
2023年06月09日 15点06分 9
level 2
把声明的Animation改成Animator
2023年06月10日 03点06分 10
1