一、游戏对象运动的本质:

是游戏游戏对象跟随每一帧在空间上发生变化。空间变化包括transform中position(绝对位置或相对位置)与rotation(所处角度)的变化。

二、实现物体的抛物线运动

方法一:

public class NewBehaviourScript : MonoBehaviour
{public float speed = 1;// Start is called before the first frame updatevoid Start(){Debug.Log("start");}// Update is called once per framevoid Update(){//设置两个方向的加速度 this.transform.position += Vector3.down * Time.deltaTime * (speed / 10);this.transform.position += Vector3.right * Time.deltaTime * 4;speed ++;  }}

方法二:

public class NewBehaviourScript : MonoBehaviour
{public float speed = 1;// Start is called before the first frame updatevoid Start(){Debug.Log("start");}// Update is called once per framevoid Update(){Vector3 change = new Vector3(Time.deltaTime * 5, -Time.deltaTime * (speed / 10) , 0);this.transform.position += change;speed ++;}
}

方法三:

public class NewBehaviourScript : MonoBehaviour
{public float speed = 1;// Start is called before the first frame updatevoid Start(){Debug.Log("start");}// Update is called once per framevoid Update(){Vector3 change = new Vector3(Time.deltaTime * 5, -Time.deltaTime * (speed / 10) , 0);this.transform.Translate(change);speed ++;}
}

代码传送门:作业3/抛物线.cs · Feyaa/3D游戏编程 - 码云 - 开源中国 (gitee.com)

三、写一个程序,实现一个完整的太阳系, 其他星球围绕太阳的转速必须不一样,且不在一个法平面上。

1.新建9个Sphere, GameObject -> 3DObject -> Sphere。Sun作为父对象,其余八大行星为Sun的子对象

2.将星球贴图放置在对象上

3.建立代码脚本

using System.Collections;
using System.Collections.Generic;
using UnityEngine;public class RoudSun : MonoBehaviour
{public Transform sun;public Transform earth;public Transform moon;public Transform mercury;public Transform mars;public Transform jupiter;public Transform uranus;public Transform venus;public Transform saturn;public Transform neptune;// Start is called before the first frame updatevoid Start(){sun.position = Vector3.zero;earth.position = new Vector3(6,0,0);moon. position = new Vector3(8,0,0);mercury.position = new Vector3(2,0,0);venus.position = new Vector3(4,0,0);mars.position = new Vector3(8,0,0);jupiter.position = new Vector3(10,0,0);saturn.position = new Vector3(12,0,0);uranus.position = new Vector3(14,0,0);neptune.position = new Vector3(16,0,0);}// Update is called once per framevoid Update(){earth.RotateAround(sun.position,Vector3.up, 10*Time.deltaTime);earth.Rotate(Vector3.up *30 *Time.deltaTime);mercury.RotateAround(sun.position,Vector3.up, 1*Time.deltaTime);mercury.Rotate(Vector3.up *30 *Time.deltaTime);venus.RotateAround(sun.position,Vector3.up, 2*Time.deltaTime);venus.Rotate(Vector3.up *30 *Time.deltaTime);mars.RotateAround(sun.position,Vector3.up, 4*Time.deltaTime);mars.Rotate(Vector3.up *30 *Time.deltaTime);jupiter.RotateAround(sun.position,Vector3.up, 5*Time.deltaTime);jupiter.Rotate(Vector3.up *30 *Time.deltaTime);saturn.RotateAround(sun.position,Vector3.up, 6*Time.deltaTime);saturn.Rotate(Vector3.up *30 *Time.deltaTime); uranus.RotateAround(sun.position,Vector3.up, 7*Time.deltaTime);uranus.Rotate(Vector3.up *30 *Time.deltaTime);neptune.RotateAround(sun.position,Vector3.up, 8*Time.deltaTime);neptune.Rotate(Vector3.up *30 *Time.deltaTime);moon.transform.RotateAround(earth.position,Vector3.up,359*Time.deltaTime);}
}

4.将脚本挂载在camera上

 代码传送门:作业3/RoudSun.cs · Feyaa/3D游戏编程 - 码云 - 开源中国 (gitee.com)

四、编程实践

阅读以下游戏脚本

Priests and Devils

Priests and Devils is a puzzle game in which you will help the Priests and Devils to cross the river within the time limit. There are 3 priests and 3 devils at one side of the river. They all want to get to the other side of this river, but there is only one boat and this boat can only carry two persons each time. And there must be one person steering the boat from one side to the other side. In the flash game, you can click on them to move them and click the go button to move the boat to the other direction. If the priests are out numbered by the devils on either side of the river, they get killed and the game is over. You can try it in many > ways. Keep all priests alive! Good luck!

程序需要满足的要求:

1.play the game ( http://www.flash-game.net/game/2535/priests-and-devils.html )

2/列出游戏中提及的事物(Objects)

3.用表格列出玩家动作表(规则表),注意,动作越少越好

4.请将游戏中对象做成预制

在 GenGameObjects 中创建 长方形、正方形、球 及其色彩代表游戏中的对象。

使用 C# 集合类型 有效组织对象

整个游戏仅 主摄像机 和 一个 Empty 对象, 其他对象必须代码动态生成!!! 。 整个游戏不许出现 Find 游戏对象, SendMessage 这类突破程序结构的 通讯耦合 语句。 违背本条准则,不给分  请使用课件架构图编程,不接受非 MVC 结构程序

1.游戏中的object :

牧师 魔鬼 小船 河 起始岸 终点岸

2.用表格列出玩家动作表

     事件    发生条件
开船   船在起始岸或者终点岸,且船上有人
在船的左方下船 船靠岸船上左边有人
在船的右方下船       船靠岸船上右边有人
起始岸的魔鬼上船  船在起始岸,船上有位置,起始岸有魔鬼
起始岸的牧师上船 船在起始岸,船上有位置,起始岸有牧师
终点岸的魔鬼上船 船在起始岸,船上有位置,终点岸有魔鬼
终点岸的牧师上船  船在起始岸,船上有位置,终点岸有牧师

3.将游戏中对象做成预制

4.建立主摄像机 和 一个 Empty 对象  

MVC结构:

UML结构:

代码结构:

代码传送门:  作业3/Priest and Devil/Assets · Feyaa/3D游戏编程 - 码云 - 开源中国 (gitee.com) (感觉难度有点大,参考了前辈的代码)

5.运行效果:

挑战成功:

挑战失败:

3D游戏设计作业(三)相关推荐

  1. 3D游戏设计作业(四)

    一.下载 Fantasy Skybox FREE, 构建自己的游戏场景 1.下载Fantasy Skybox   2.创建material   3.将下载好的素材拖动到material中  4.显示效 ...

  2. 3D游戏编程 作业三 牧师与魔鬼

    提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档 文章目录 前言 一.任务要求 二. 任务分析 1.游戏规则 2.游戏对象 3.动作表 二. 项目展示 1.mvc架构 导演 SSDir ...

  3. 3D游戏设计作业5:改进飞碟(Hit UFO)游戏

    改进飞碟(Hit UFO)游戏: 游戏截图: 1,作业要求 游戏内容要求: 1,按adapter模式设计图修改飞碟游戏 2,使它同时支持物理运动与运动学(变换)运动 2,设计思路 1,分析adapte ...

  4. 3D游戏设计第六次作业——打飞碟物理模式

    3D游戏设计第六次作业--打飞碟物理模式 1 概述 在上一次的作业实现的基础上增加了物理模式,通过给飞碟增加刚体组件,实现飞碟拥有物理特性,会发生碰撞,也会收到重力影响. 2 代码讲解 2.1 与上一 ...

  5. 3D游戏设计读书笔记二

    3D游戏设计读书笔记二 一.简答题 • 解释 游戏对象(GameObjects) 和 资源(Assets)的区别与联系.   GameObjects是一个具体的实例,Assets是包括诸多游戏素材的资 ...

  6. 3D游戏设计读书笔记九

    3D游戏设计读书笔记九 本次作业五选一,我选择制作血条预制设计,要求如下: 分别使用 IMGUI 和 UGUI 实现 使用 UGUI,血条是游戏对象的一个子元素,任何时候需要面对主摄像机 分析两种实现 ...

  7. 3d游戏设计读书笔记六

    3d游戏设计读书笔记六 一.改进飞碟(Hit UFO)游戏: 游戏内容要求: 按 adapter模式 设计图修改飞碟游戏 使它同时支持物理运动与运动学(变换)运动 更改原 UFO_action 类 为 ...

  8. 3D游戏设计读书笔记七

    3D游戏设计读书笔记七 智能巡逻兵 提交要求: 游戏设计要求: 创建一个地图和若干巡逻兵(使用动画): 每个巡逻兵走一个3~5个边的凸多边型,位置数据是相对地址.即每次确定下一个目标位置,用自己当前位 ...

  9. 中山大学3D游戏设计读书笔记 unity3D Note6

    本文利用订阅与发布模式实现智能巡逻兵游戏 游戏演示视频地址:http://www.iqiyi.com/w_19rxsmp5kx.html 游戏具体代码地址:https://github.com/dic ...

最新文章

  1. HTML5 进阶系列:indexedDB 数据库
  2. mysql中一个表怎么查询多以上的信息,MySQL怎么样实现多个表的或查询?
  3. RedHat 6 安装配置Tomcat 7
  4. java21个知识点重点_java21个知识点重点
  5. Redis pub/sub机制在实际运用场景的理解(转载)
  6. 5 CO配置-控制-一般控制-维护成本控制范围
  7. 计算机网络中seq,计算机网络A卷及参考答案
  8. 计算机室和电子备课室管理制度,电子备课室管理制度
  9. c语言程序学生档案管理系统,C语言 班级档案管理系统实现
  10. Linux基础入门(详细版)
  11. Modern Radar for Automotive Applications(用于汽车应用的现代雷达)
  12. jpa级联添加_jpa级联(Cascade)操作
  13. Kali使用Metasploit内、外网渗透windows系统
  14. 麒麟开源堡垒机银行行业设计方案
  15. java环境变量classpath的作用_JAVA环境变量中 classpath、path、JAVA_HOME的作用
  16. 重学Android基础系列篇(五):Android虚拟机指令
  17. 计算机cpu多大,电脑的cpu频率多少算正常
  18. failed to parse the connection string near ‘;serverTimezone=Hongkongamp;characterEncoding=utf-8amp
  19. 集团施工企业双预防系统,落实企业安全生产责任,保障安全生产费有效投入
  20. Spark物理计划和CBO和AQE

热门文章

  1. MySQL按天统计一周没有数据补0
  2. 2022 智简魔方财务快云模板前台+购物车+用户中心模板 全解 无授权
  3. Openstack 对象存储服务之争:Ceph或者Swift
  4. 支持两个USB Type-C接口都能投屏的便携显示器方案
  5. 一文读懂什么是进程、线程、协程
  6. vue刷新当前页面--provide / inject 用法
  7. 《精通.NET互操作:P/Invoke、C++ Interop和COM Interop》
  8. 毕业薪酬行业第一?计算机+金融交叉学科真香
  9. [HarmonyOS][鸿蒙专栏开篇]快速入门OpenHarmony的LiteOS微内核
  10. 论ICC(intercoin capital)优越性!为什么选择ICC