最近在写关于相机跟随的逻辑,其实最早接触相机跟随是在Unity官网的一个叫Roll-a-ball tutorial上,其中简单的涉及了关于相机如何跟随物体的移动而移动,如下代码: using UnityEngine; using System.Collections; public class CameraController : MonoBehaviour { public GameObject player; private Vector3 offset; void Start () { o…
1.让cube沿着矩形四个点运动 using System.Collections; using System.Collections.Generic; using UnityEngine; public class cube : MonoBehaviour { // Use this for initialization private Vector3 vec; ; void Start () { vec = transform.position;//存取坐标 } ; ; // bool b…
固定相机跟随 这种相机有一个参考对象,它会保持与该参考对象固定的位置,跟随改参考对象发生移动 using UnityEngine; using System.Collections; public class CameraFlow : MonoBehaviour { public Transform target; private Vector3 offset; // Use this for initialization void Start() { offset = target.posit…
固定相机跟随 这种相机有一个参考对象,它会保持与该参考对象固定的位置,跟随改参考对象发生移动 using UnityEngine; using System.Collections; public class CameraFlow : MonoBehaviour { public Transform target; private Vector3 offset; // Use this for initialization void Start() { offset = target.posit…
最近写了一个跑酷游戏,总结下里面的知识点:O(∩_∩)O~ using UnityEngine; using System.Collections; public class Demo : MonoBehaviour { public Vector3 lastMonseDown; /// <summary> /// 判断手指触摸的方向 /// </summary> /// <returns></returns> TouchDir GetTouchDir()…
参考网站:https://blog.csdn.net/pz789as/article/details/79540890 using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.Tilemaps; public class CreateTileMap : MonoBehaviour { public Tilemap tilemap;//引用的Tilemap pu…
1.对Tags进行管理 设置一个全局的类,类似如下: public class Tags:MonoBehaviour{ public const string player="Player"; } 调用Tags.player 2.发送消息 unity中每一个对象都有SendMessage,BroadcastMessage,SendMessageUpwards 三个发送消息的方法! 具体使用方法参考:http://www.cnblogs.com/MrZivChu/p/sendmessag…
using UnityEngine; public class ScreenToUI : MonoBehaviour { public const float UI_Width = 1366f; public const float UI_Height = 768f; public readonly static float Screen_Width_Half = Screen.width / 2f; public readonly static float Screen_Height_Half…
原地址:http://www.cnblogs.com/88999660/p/3262656.html using UnityEngine; using System.Collections; public class PlayerScript : MonoBehaviour { public GameObject cameraObject; public float cameraDistance;//the distance the camera should be palced from th…
调用其它组件中成员 通过GameObject(游戏物体). Base class for all entities in Unity scenes. 是Unity场景里面所有实体的基类. 可以理解为两个类间的访问,定义一个超类用其中一个类实现. 默认的gameObject为当前组件.transform为变换,有常用属性position(Vector3三维向量). 熟记transform下属性和方法作用. transform.translate() 平移,给定vector3,给定坐标系'物体坐标…