Unity2020 控制刚体运动

1.代码

 1 using System.Collections;
 2 using System.Collections.Generic;
 3 using UnityEngine;
 4 
 5 public class Player : MonoBehaviour
 6 {
 7     public float speed = 1;
 8     private Rigidbody rd;
 9 
10     // Start is called before the first frame update
11     void Start()
12     {
13         rd = GetComponent<Rigidbody>();
14     }
15 
16     // Update is called once per frame
17     void Update()
18     {
19         float h = Input.GetAxis("Horizontal");
20         rd.AddForce(new Vector3(h, 0, 0) * speed);
21         float v = Input.GetAxis("Vertical");
22         rd.AddForce(new Vector3(0, 0, v) * speed);
23     }
24 }

2.设置

Unity2020 控制刚体运动

 

 

Unity2020 控制刚体运动

 

上一篇:测试工程师的转型探索:如何让产品质量变得更好?


下一篇:人脸识别数据集的建立及应用