我试图以RigidBody2D速度向上移动对象,但是代码不起作用。
SantaRb.velocity = new Vector3(0f, rocketFlyBoost, 0f);
Vector3 mPosition = Camera.main.ScreenToWorldPoint(new Vector2(Input.mousePosition.x, transform.position.y));
transform.position = Vector2.Lerp(transform.position, mPosition, moveSpeed);
Vector3 difference = Camera.main.ScreenToWorldPoint(Input.mousePosition) - transform.position;
difference.Normalize();
float rotation_z = Mathf.Atan2(difference.y, difference.x) * Mathf.Rad2Deg;
transform.rotation = Quaternion.Euler(0f, 0f, rotation_z -90f);
如果我注释掉第一行之外的所有行,则该对象移动正常。我错了,非常感谢!