study/first_study/Assets/Player/Excution/SimpleLineRender.cs

26 lines
618 B
C#
Raw Normal View History

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);
}
}