luckstar 发表于 2012-12-30 19:53

Unity3D定义曲线摄像机环绕物体教程

源文件下载:
此脚本可以让你在U3D内设置曲线并让物体沿着你设置的曲线进行运动。

1.新建一个空的GameOject(用来存放路径点),在它的层次下新建几个Cube作为路径点,再新建一个GameOject作为运动的物体(Cube或Sqhere)。



2.为运动的物体添加SplineController脚本.



3. 如图,选中移动物体对象,打开属性面板,将存放路径点的对象Game拖曳到上一步添加脚本后预留的接口上,系统将自动计算路径,并以红色线条显示在场景中。

你可以通过改变路径点Cube位置来调整路径,或者添加新的路径点,系统都会自动计算路径,你要移动的物体将会沿着你设置的路径移动。


4. 下面介绍添加脚本后生成的接口的作用,


Spline Root :自动计算路径曲线接口。
Duration :移动一次所持续时间,即可以控制移动速度,默认10秒。
Orientation Modern :控制移动物体的角度、方向,可选两项:
            NODE:角度固定不变。
            TANGENT:将与曲线正切动态改变角度。
Wrap Mode :循环模式,可选两项:
         ONCE:只运行一次。
         LOOP:一直循环。
Auto Strart :是否自动计算曲线起始点。
Auto Close :是否自动计算曲线终结点。
Hide On Execute :程序运行后路径点是否可见。

gino_adrian 发表于 2013-1-14 14:16

抛出异常.
ArgumentException: Key 'Cube' already exists in list.
System.Collections.SortedList.PutImpl (System.Object key, System.Object value, Boolean overwrite) (at /Applications/buildAgent/work/3df08680c6f85295/mcs/class/corlib/System.Collections/SortedList.cs:522)
System.Collections.SortedList.Add (System.Object key, System.Object value) (at /Applications/buildAgent/work/3df08680c6f85295/mcs/class/corlib/System.Collections/SortedList.cs:247)
SplineController.GetTransforms () (at Assets/SplineController.cs:130)

asdf 发表于 2013-4-20 08:13

没太搞明白。。。private string mState = "";请问mState这个是干什么用的。。。NullReferenceException: Object reference not set to an instance of an object
SplineInterpolator.Update () (at Assets/SplineController_CS_iPhone/SplineInterpolator.cs:391)
新手求理解。

ziroset 发表于 2016-7-19 18:38

赞赞个,学习学习啊。

mustang5200 发表于 2016-11-13 12:25

好东西要顶啊

极乐净土 发表于 2017-1-20 10:17


膜拜中。。。。

lixingzhi 发表于 2017-1-29 12:07

摄像机,掌握好后,可以升级

sftz01 发表于 2017-5-1 23:57


感谢楼主的无私分享!

susu 发表于 2017-5-10 17:33

楼主是超人

自力 发表于 2017-5-10 17:25

顶顶多好
页: [1] 2 3
查看完整版本: Unity3D定义曲线摄像机环绕物体教程