728x90
    
    
  반응형
    
    
    
  
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ObjectLine : MonoBehaviour
{
    LineRenderer lineRenderer;
    public Transform[] pathPoints; // 오브젝트들의 위치를 순서대로 저장하는 배열
    private void Start()
    {
        lineRenderer = GetComponent<LineRenderer>();
        DrawPath();
    }
    private void Update()
    {
        DrawPath(); // 포지션 고정일 시 제거
    }
    void DrawPath()
    {
        lineRenderer.positionCount = pathPoints.Length; // 라인 렌더러의 버텍스 수를 경로의 포인트 수로 설정
        for (int i = 0; i < pathPoints.Length; i++)
        {
            lineRenderer.SetPosition(i, pathPoints[i].position); // 라인 렌더러의 각 버텍스 위치 설정
        }
    }
}
728x90
    
    
  반응형
    
    
    
  'C#' 카테고리의 다른 글
| [유니티] TMP 폰트 (0) | 2024.01.11 | 
|---|---|
| [유니티]방향키로 움직이고 마우스로 화면 회전하기 (0) | 2023.08.29 | 
| [유니티] 코루틴을 이용한 라이트 밝기 조절 (0) | 2023.08.28 | 
| 키보드 입력 테스트 프로그램 ( 키 입력 시각화 프로그램 ) (5) | 2020.01.28 | 
| 키보드 입력 시각화 프로그램 ( 배포 ) (0) | 2020.01.10 | 
 
                    
                   
                    
                  