中山大学3D游戏HW2

3D游戏HW2

简答并用程序验证
游戏对象运动的本质是什么?

游戏对象运动的本质是游戏对象每一帧在空间上的变化,例如位置发生变化(Position),或者发生了旋转(Rotation)。

请用三种方法以上方法,实现物体的抛物线运动。
  1. 新建一个Vector3变量,为change,水平方向上的变化每一帧都是固定的,水平速度 * 时间间隔,竖直方向上为竖直速度 * 时间间隔,z方向为0。
 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 
 public class Behavior : MonoBehaviour {
 
 	// Use this for initialization
 	void Start () {
 		
 	}
 	private float verticalSpeed = 0.00f;
 	public float horizontalSpeed = 5.00f;
 	const float g = 0.098f;
 	// Update is called once per frame
 	void Update () {
 		Vector3 change = new Vector3 (Time.deltaTime * horizontalSpeed, -Time.deltaTime * verticalSpeed, 0.0f);
 		this.transform.position += change;
 		verticalSpeed += g;
 	}
 }
  1. 与1类似,但是不调用position,而是调用Translate函数
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Behavior : MonoBehaviour {

	// Use this for initialization
	void Start () {
		
	}
	private float verticalSpeed = 0.00f;
	public float horizontalSpeed = 5.00f;
	const float g = 0.098f;
	// Update is called once per frame
	void Update () {
		Vector3 change = new Vector3 (Time.deltaTime * horizontalSpeed, -Time.deltaTime * verticalSpeed, 0.0f);
		this.transform.Translate (change);
		verticalSpeed += g;
	}
}
  1. 直接运用position的加减来完成
using Syst
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值