English 中文(简体)
第2D条
原标题:Unity 2D object not moving

我试图通过学习团结建设一些东西,但我有问题。 我试图打造一个简单的2DBrick碎游戏,但首先我不得不停下来,因为这个物体没有移动。 我确实进行了研究,但我无法得出结论。 当我与僵硬的人一起解决问题时,该物体 moved倒,但我希望它离开,有权开始。 我也赞同该守则。 此外,团结的篮子不是静态的, does似乎有任何问题。 当我打电话给更新职能时。 洛奇,在我撰写时,我可以看到“团结”会。 你们能否帮助?

public class PaddleController : MonoBehaviour
{
    [SerializeField]
    float speed;

    [SerializeField]
    float leftTarget, rightTarget;

    void Update()
    {
        float h = Input.GetAxis("Horizontal");
        transform.Translate(Vector2.right * h * speed * Time.deltaTime);

        //if (transform.position.x < leftTarget)
        //    transform.position = new Vector2(leftTarget, transform.position.y);

        //if (transform.position.x > rightTarget)
        //    transform.position = new Vector2(rightTarget, transform.position.y);

        Vector2 temp = transform.position;
        temp.x = Mathf.Clamp(temp.x, leftTarget, rightTarget); 
        transform.position = temp;
    }
}

与此同时,团结湖3.5.0座已经安装了2022.2.2f1 LTS。 在法典方面,Im使用VS 2022。

我在互联网上进行了研究。 我与里特人一道树立了榜样。 它只是走了这条路。 我审查了因特网上共有的问题,但我未能得出结论。 我期望了解问题的根源。

问题回答

暂无回答




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签