繁体   English   中英

transform.Rotate在Android上导致fps下降

[英]transform.Rotate causing fps drop on android

使用transform.Roadate与对撞机和精灵渲染器在游戏对象上旋转会导致游戏在Android上落后。 关于如何改善这一点有什么想法?

我曾尝试禁用对撞机,并为运动学设置了刚体,如另一篇文章中所述,但无济于事。

这是旋转对象的组成部分:

在此处输入图片说明

这是用于旋转的脚本:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class ObjectMove : MonoBehaviour
{
    //Rotate
    float speed = 150.0f;
    public bool forward = false;
    public bool back = false;
    public bool down = false;
    public bool up = false;
    public bool right = false;
    public bool left = false;


    void Update()
    {
        //Rotate
        if(forward == true)
        {
            transform.Rotate(Vector3.forward * speed * Time.deltaTime);
        }
        if (back == true)
        {
            transform.Rotate(Vector3.back * speed * Time.deltaTime);
        }
        if (down == true)
        {
            transform.Rotate(Vector3.down * speed * Time.deltaTime);
        }
        if (up == true)
        {
            transform.Rotate(Vector3.up * speed * Time.deltaTime);
        }
        if (right == true)
        {
            transform.Rotate(Vector3.right * speed * Time.deltaTime);
        }
        if (left == true)
        {
            transform.Rotate(Vector3.left * speed * Time.deltaTime);
        }


}

因此,我基本上在检测器中手动将布尔值更改为true / false,以管理我希望游戏对象旋转的方向。 还有另一种方式可以做到而又不会导致如此低的fps吗? 在PC上,它也会下降,但并不明显。

正如某些人在评论中提到的,脚本的另一部分确实导致fps下降。 我以为当时甚至没有执行,但显然是。 我的错。 谢谢您的帮助!

暂无
暂无

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

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