Unity3D作业二

本文介绍了使用Unity3D实现游戏对象运动,包括物体的抛物线运动及构建太阳系模拟。在太阳系模拟中,行星围绕太阳以不同速度和角度旋转。此外,还详细解析了谜题游戏《Priests and Devils》的规则,列出游戏对象和玩家动作表,并提出了游戏对象预制、集合类型组织和遵循MVC结构的编程要求。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1. 简答题

  • 游戏对象运动的本质是什么?

游戏对象运动的本质是其transform属性的position、rotation和scale等属性的变化。

  • 请用三种方法以上方法,实现物体的抛物线运动。(如,修改Transform属性,使用向量Vector3的方法…)

1. 通过transform.Translate方法

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Move : MonoBehaviour {
    private Vector3 g;
    private Vector3 vy;
    private Vector3 vx;
    private float t;

    // Use this for initialization
    void Start()
    {
        t = Time.deltaTime;
        g = new Vector3(0, 9.8f, 0);
        vy = new Vector3(0, 0, 0);
        vx = new Vector3(0, 0, 30);
    }

    // Update is called once per frame
    void FixedUpdate()
    {
        Vector3 target = (vy + vx) * t;
        transform.Translate(target);
        vy -= g * t;
    }
}

2. 通过Vector3.MoveTowards方法


                
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值