如何修复“类型向量lerp中不存在类型名称lerp或MoveForward”?

问题描述 投票:0回答:1

我尝试将客户端对象类中的new Vector3.(x,y,z)更改为new Vector3.MoveTowards(),并告知

the type name lerp or MoveForward does not exist in the type vector 3

我正在使用ZeroMQ统一控制一个多维数据集,并希望该多维数据集缓慢移动到下一个为其分配的位置。

是否发生此问题,因为我的脚本中没有设置速度?

我已经尝试将var position更改为float position,但这也没有解决问题。

public class ClientObject : MonoBehaviour
{
    private NetMqListener _netMqListener;

    private void HandleMessage(string message)
    {
        var splittedStrings = message.Split(' ');
        if (splittedStrings.Length != 3) return;
        var x = float.Parse(splittedStrings[1]);
        var y = float.Parse(splittedStrings[1]);
        var z = float.Parse(splittedStrings[1]);
        transform.position = new Vector3.(x,y,z);
    }
}

public class ServerObject : MonoBehaviour
{
    public bool Connected;
    private NetMqPublisher _netMqPublisher;
    private string _response;
    private Transform target;

    private void Start()
    {
        _netMqPublisher = new NetMqPublisher(HandleMessage);
        _netMqPublisher.Start();
    }

    private void Update()
    {
        var position = transform.position;
        _response = "{position.x} {position.y} {position.z}";
        Connected = _netMqPublisher.Connected;
    }
}
c# unity3d zeromq
1个回答
2
投票

Vector3.LerpVector3.Lerp都是Vector3.MoveTowards方法。

[它们与没有Vector3.MoveTowards关键字的相应类static一起使用:

Vector3

new

我不知道此transform.position = Vector3.MoveTowards(currentPos, targetPos, speed); 调用的性质,但似乎不会被重复调用,而仅被重复[,因此您可能会对使用transform.position = Vector3.Lerp(startPos, endPos, interpolationFactor); 这样的名称感兴趣,例如

HandleMessage
© www.soinside.com 2019 - 2024. All rights reserved.