C# 统一-使用旧坐标和坐标之间的线长度获取新坐标
我正在制作一个游戏,玩家对象围绕原点运行。我希望玩家能够使圆圈变大或变小。我有新坐标和原点之间的距离,我有两个旧坐标:当前玩家坐标和原点。如何使用直线长度将新坐标与旧坐标和原点对齐C# 统一-使用旧坐标和坐标之间的线长度获取新坐标,c#,unity3d,C#,Unity3d,我正在制作一个游戏,玩家对象围绕原点运行。我希望玩家能够使圆圈变大或变小。我有新坐标和原点之间的距离,我有两个旧坐标:当前玩家坐标和原点。如何使用直线长度将新坐标与旧坐标和原点对齐 我使用的是unity和c#。我们能看看你已经有了什么吗?这使得这个过程更容易 也许我能帮你 你只需要更新玩家的位置“使圆圈变大”。例如: public class Example : MonoBehaviour { private Vector3 target = new Vector3(5.0f, 0.0f
我使用的是unity和c#。我们能看看你已经有了什么吗?这使得这个过程更容易 也许我能帮你 你只需要更新玩家的位置“使圆圈变大”。例如:
public class Example : MonoBehaviour
{
private Vector3 target = new Vector3(5.0f, 0.0f, 0.0f);
void Update()
{
// Spin the object around the world origin around the Yaxis 20 degrees/second.
transform.RotateAround(target, Vector3.up, 30 * Time.deltaTime);
}
Public void IncreaseDistance(float amount){
//you need a vector in de direction you want to move to. You get this by
// calculating the distance vector from the target to this.gameObject. Then normalize it
Vector3 direction = (transform.position - target).normalize; //to - from;
transform.position += direction * amount
}
}