如何使摄像机每次移动到上升时向后移动?
我希望玩家向上移动相机以在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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以执行此步骤来执行以下任务:
在您的运动脚本中获取相机的引用。
在您的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);