-
Notifications
You must be signed in to change notification settings - Fork 0
/
GolfTrailController.cs
41 lines (36 loc) · 1.24 KB
/
GolfTrailController.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
namespace walking_mod
{
public class GolfTrailController : MonoBehaviour
{
public LineRenderer lineRenderer;
public int positionsCount = 20; // Number of positions to store in the line renderer.
private Vector3[] positions;
void Start()
{
positions = new Vector3[positionsCount];
lineRenderer = GetComponent<LineRenderer>();
lineRenderer.material = new Material(Shader.Find("HDRP/Lit"));
lineRenderer.material.color = new Color32(200, 200, 250, 120);
lineRenderer.positionCount = positionsCount;
lineRenderer.startWidth = .03f;
lineRenderer.endWidth = 0f;
}
void Update()
{
// Shift the position array to the right and insert the new position at index 0.
for (int i = positions.Length - 1; i > 0; i--)
{
positions[i] = positions[i - 1];
}
positions[0] = transform.position;
// Update the line renderer positions.
lineRenderer.SetPositions(positions);
}
}
}