EngediKimHyeYoung / Unity

0 stars 0 forks source link

마우스 커서 - FollowCursor.cs #6

Open EngediKimHyeYoung opened 2 years ago

EngediKimHyeYoung commented 2 years ago

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

public class FollowCursor : MonoBehaviour {

void Start()
{
    //Cursor.visible = false;
}

void Update()
{
    Vector2 pos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
    transform.position = pos;
}

}

EngediKimHyeYoung commented 2 years ago

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

public class FollowCursor : MonoBehaviour { private TrailRenderer trail; // Start is called before the first frame update void Start() { trail = GetComponent(); Cursor.visible = false; }

// Update is called once per frame
void Update()
{
    if (Input.GetKeyDown(KeyCode.Space))
    {
        trail.startColor = Color.green;
        trail.endWidth = 3;
    }
    Vector2 pos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
    transform.position = pos;
}

}