-
Notifications
You must be signed in to change notification settings - Fork 1
/
LaserGunController.cs
50 lines (43 loc) · 1.67 KB
/
LaserGunController.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
42
43
44
45
46
47
48
49
50
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class LaserGunController : MonoBehaviour
{
private LineRenderer TheLaserLineRenderer;
public Transform ThePlayerTarget;
public Transform TheDalekLaserGun;
private bool DisplayRay;
// =====================================================================
// =====================================================================
// Start is called before the first frame update
void Start()
{
TheLaserLineRenderer = GetComponent<LineRenderer>();
DisplayRay = false;
}
// =====================================================================
// Update is called once per frame
void Update()
{
// Will need to continous Update the Line as th Dalek and Player move in space
TheLaserLineRenderer.SetPosition(0, TheDalekLaserGun.transform.position);
if (DisplayRay)
{
Vector3 PlayerChestheight = ThePlayerTarget.transform.position + new Vector3(0.0f, 3.0f, 0.0f);
TheLaserLineRenderer.SetPosition(1, PlayerChestheight);
}
else TheLaserLineRenderer.SetPosition(1, TheDalekLaserGun.transform.position);
TheLaserLineRenderer.positionCount = 2;
} // Update
// =====================================================================
public void EnableRay()
{
DisplayRay = true;
}
public void DisableRay()
{
DisplayRay = false;
}
// =====================================================================
// =====================================================================
}