简答题
-
游戏对象运动的本质是什么?
游戏对象的运动是游戏对象随着时间进行空间坐标、旋转角、大小的变化。本质上是通过矩阵运算改变对象的空间属性。 -
请用三种方法以上方法,实现物体的抛物线运动。
-
直接计算x坐标、y坐标
using System.Collections; using System.Collections.Generic; using UnityEngine; public class Move1 : MonoBehaviour { public float vx = 1; public float vy = 1; void Update () { this.transform.position -= Vector3.down * Time.deltaTime * vy; this.transform.position += Vector3.right * Time.deltaTime * vx; vy += y; } } -
使用向量vector
using System.Collections; using System.Collections.Generic; using UnityEngine; public class Move2 : MonoBehaviour { public float vx = 1; public float vy = 1; void Update () { this.transform.position += Time.deltaTime * new Vector3(vx, -vy, 0);; vy += 1 ; } } -
使用transform.translate
public class Move3 : MonoBehaviour { public vx = 1; public vy = 1; public Vector3 = new Vector3(); void Update() { transform.Translate(Time.deltaTime * new Vector3(vx, vy, 0), Space.World); vy += 1; } }
本文探讨了游戏对象运动的本质,即通过矩阵运算改变空间属性。详细介绍了三种实现抛物线运动的方法:直接计算坐标、使用向量Vector和transform.translate。深入理解游戏物理引擎的关键。
1万+

被折叠的 条评论
为什么被折叠?



