zoukankan      html  css  js  c++  java
  • 短短几行代码实现让摄像机跟随着物体效果

      今天逛技术贴的时候发现了一种非常简单的方法实现让摄像机跟随物体运动的效果,仅仅短短几行就能实现,不过想想这种方法还是有很多不足的地方,

    就是相机只能跟随着物体移动,不能跟随着物体旋转,后续我会完善让它达到真正跟随的效果,这里先分享下初步的代码部分

    using UnityEngine;
    using System.Collections;
    
    public class FollowMe : MonoBehaviour
    {
        public Transform traPlayer;
        Vector3 offset { set; get; }
        // Use this for initialization
        void Start()
        {
            offset = traPlayer.position - this.transform.position;
        }
    
        // Update is called once per frame
        void Update()
        {
            this.transform.position = traPlayer.position - offset;
        }
    }

    未完待续。。。。。。。

  • 相关阅读:
    负数之美
    css重设
    编码问题
    wed的各种前端打印方法(3)CSS
    表单
    学习前端心得
    去除input,a,按键链接时出现的虚线方法
    加载事件js代码
    深入C#数据类型
    查找
  • 原文地址:https://www.cnblogs.com/springword/p/5962621.html
Copyright © 2011-2022 走看看