blob: e619f0d64a9ce112164df284db2cef90c9fc8410 (
plain)
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
|
using UnityEngine;
public class RaycastTrail : MonoBehaviour
{
private ProjectileHit hit;
private Vector3 lastPosition;
private SpawnerHolder spawnerHolder;
private void Start()
{
hit = GetComponent<ProjectileHit>();
spawnerHolder = GetComponent<SpawnerHolder>();
lastPosition = base.transform.position;
}
private void LateUpdate()
{
Vector3 direction = base.transform.position - lastPosition;
Ray ray = new Ray(lastPosition, direction);
Physics.Raycast(ray, out var hitInfo, Vector3.Distance(base.transform.position, lastPosition));
if ((bool)hitInfo.collider)
{
hit.Hit(hitInfo);
}
lastPosition = base.transform.position;
}
}
|