study/first_study/Assets/Player/Excution/SimpleLineRender.cs
jh04010421 339a595ac1 윤지호 | 유니티 연습
20226.01.27 수정 (태그 구현중, 오브젝트별 컴포넌트 배치필요)
2026-01-27 20:58:00 +09:00

26 lines
618 B
C#

using UnityEngine;
public class SimpleLineRender : MonoBehaviour
{
private LineRenderer line;
public Transform player;
public Transform target;
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
line = gameObject.GetComponent<LineRenderer>();
line.positionCount = 2;
}
// Update is called once per frame
void Update()
{
if(target == null)
{
Destroy(gameObject);
}
line.SetPosition(0, player.position);
line.SetPosition(1, target.position);
}
}