关于 游戏寻路 中怎么超出地图外回到地图左边

 
 
public class Move : MonoBehaviour {

    public float minX;
    public float maxX;
    public float speed;

	// Use this for initialization
	void Start ()
    {
	
	}
	
	// Update is called once per frame
	void Update ()
    {
        Vector3 v = new Vector3(transform.position.x + Time.deltaTime * speed, transform.position.y, transform.position.z);
        if (v.x > maxX)
        {
            v.x = minX;
        }
        if (v.x<minX)
        {
            v.x = maxX;
        }
        transform.position = v;
	}

    
}

很简单的逻辑,恍然大悟。

猜你喜欢

转载自blog.csdn.net/qq_53211468/article/details/126125769