Unity3d 中的相机脚本(也许还有一般脚本)

发布于 2024-11-25 13:41:49 字数 179 浏览 1 评论 0原文

在游戏中,就摄像机控制脚本而言,您是否有一个处理所有摄像机的“摄像机控制脚本”,或者为每个单独的摄像机(玩家摄像机、过场摄像机等)编写一个脚本。

我只是想找出统一处理脚本的正确方法,从长远来看,这将使事情变得简单并提高内存效率。

摄像机动作将跟随玩家的玩家摄像机,或者在过场动画中平移或在不同的过场动画中保持静止

In a game, as far as camera controlling scripts, would you have one "camera control script" that handles all the cameras, or a script for each individual camera (player camera, cutscene cameras etc).

I'm just trying to figure out the proper way to handle scripting in unity that will keep things simple in the long run as well as be memory efficient.

Camera actions would be following the player for the player camera, or panning around a cutscene or staying still for a different cutscene

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

时光是把杀猪刀 2024-12-02 13:41:49

这实际上取决于场景/工作流程/生产管道,以哪种方式组织它并不重要,但如果您对脚本编写不太满意,我会说将其全部放在一个文件中可能是处理它的最佳方法眼下。

我通常会说,如果您计划重用代码段,那么保持模块化通常是一件好事,即每个脚本一个类。

编辑:对于您的具体问题,我将有一个系统,您可以在一个(或多个)摄像机之间进行切换,这些摄像机在脚本点之间进行转换,即存储的矢量3变量(用于静态摄像机和电影)和具有运动脚本的主摄像机与之相关。通过这种方式,您可以最大限度地减少场景中使用的摄像机数量,并且可以根据需要多次重复使用静态摄像机。

处理数据存储的一种简洁方法可能是使用一个结构数组,它可以存储您需要的所有数据,即相机位置、旋转、FOV 等

It really depends on the scenario/work flow/production pipe, it really doesn't matter which way you organise it but if you are less comfortable with scripting I would say putting it all in one file is probably the best way to deal with it at the moment.

I would normally say that if you plan to reuse segments of code its generally a good thing to keep things modular i.e. one class per script.

EDIT: To your specific problem, I would have a system in which you switch between one (or more) camera/s that translates between scripted points i.e. stored vector3 variables (for static cameras and cinematic) and the main camera which has the movement script associated with it. This way you minimise the amount of cameras you are using in your scene and you can reuse the static cameras as many times as you need to.

A tidy way to deal with the data storing might be to use an array of structs that can store all the data you need, i.e the cameras position, rotation, FOV etc

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文