如何使摄像机每次移动到上升时向后移动?

发布于 2025-02-11 15:44:05 字数 113 浏览 2 评论 0原文

我希望玩家向上移动相机以在Z位置向后移动一步,而当玩家跌倒时也相反。 我真的需要一个人来回答我,我是新手制作游戏的新手,这个问题持续了很长时间,所以如果有人能提供帮助,我会为此感到高兴!

那怎么做?

I want every step the player moves up the camera to move back one step in position z, and also the opposite when the player falls down.....
I really need someone to answer me I am new to making games and this problem stay with me for a long time so if anyone can help I will be so happy about that!!

So how to do it??

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

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

发布评论

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

评论(1

新雨望断虹 2025-02-18 15:44:06

您可以执行此步骤来执行以下任务:

在您的运动脚本中获取相机的引用。
在您的UP移动功能中,通过减去您希望相机移动的数量移动相机以z轴向后移动:

float step = 1; camera.transofrm.position = new vector3(camer.transofrm.position.x,camera.transofrm.position.y,camera.transofrm.position.z-Step);

使用此代码行,您的相机将返回在Z中,每次播放器上升。
通过仅在相机的y轴上添加值:

camera.transofrm.position = new vector3(camera. transofrm.position.x,camera.transofrm.position.y+step,camera.transofrm。 position.z);

You can do this step to do the following task:

In your movement script get reference of your camera.
In your up movement function move your camera back in z axis by subtracting the amount you want camera to move :

float Step = 1; Camera.transofrm.position = new Vector3(Camera.transofrm.position.x,Camera.transofrm.position.y,Camera.transofrm.position.z-Step);

With this line of code your camera will go back in z each time player move up.
Do the same for fall down by just adding value to y axis of camera :

Camera.transofrm.position = new Vector3(Camera.transofrm.position.x,Camera.transofrm.position.y+Step,Camera.transofrm.position.z);

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