简体   繁体   English

Unity3D从左向右移动相机,反之亦然C#

[英]Unity3D Moving Camera from left to right and vice versa C#

How to make camera move constantly from left to right and vice versa relatively to screenCenter and without inputs, i mean automatically from the start of the game. 如何使摄像头相对于screenCenter从左向右不断移动,反之亦然,而无需输入,我的意思是从游戏开始就自动开始。 By 'move' I mean 'watch' like as if you were turning your head to the right and to the left without changing an original position. “移动”是指“观看”,就好像您在不更改原始位置的情况下将头向右和向左旋转一样。

This is a simple example of turning script (tune it to whatever suits you best) 这是一个转换脚本的简单示例(将其调整为最适合您的方式)

int timer = 0;
int direction = 1;
// Update is called once per frame
void Update () {
    if (timer % 50 == 0)
        direction *= -1;
    transform.Rotate (new Vector3 (0, 1 * direction, 0));
    timer++;
}


Also, check out Unity Answers they should be of more help 另外,请查看Unity Answers,它们应该有更多帮助

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM