unity运行后物体跟随鼠标移动并旋转(无法放下,未完善)

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class tuozhuaai : MonoBehaviour
{
    private Vector3 DHJI;
    private Vector3 fhf;
    // Start is called before the first frame update
    void Start()
    {
        DHJI = Camera.main.WorldToScreenPoint(transform.position);
        fhf = DHJI - Input.mousePosition;
    }

    // Update is called once per frame
    void Update()
    {
        transform.position = Camera.main.ScreenToWorldPoint(Input.mousePosition + fhf);
    }
}

猜你喜欢

转载自blog.csdn.net/aorilfj/article/details/127932969