gun elements added and uvs updated to better space out texture.
This commit is contained in:
68
Assets/Scripts/Pistol/PistolComponent.cs
Normal file
68
Assets/Scripts/Pistol/PistolComponent.cs
Normal file
@ -0,0 +1,68 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class PistolComponent : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
private Light targetingLight;
|
||||
|
||||
private bool IsEnabled = false;
|
||||
|
||||
GameObject targetObject;
|
||||
[SerializeField]
|
||||
GameObject targetObjectPrefab;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
private void FixedUpdate()
|
||||
{
|
||||
if (this.IsEnabled)
|
||||
{
|
||||
Ray ray = new Ray(transform.position, transform.up);
|
||||
RaycastHit hit;
|
||||
if (Physics.Raycast(ray, out hit, 50))
|
||||
{
|
||||
print(hit.transform.name);
|
||||
targetObject.gameObject.transform.position = hit.point;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
public void Enable()
|
||||
{
|
||||
IsEnabled = true;
|
||||
if (targetObject == null)
|
||||
{
|
||||
targetObject = Instantiate(targetObjectPrefab);
|
||||
|
||||
}
|
||||
}
|
||||
public void Disable()
|
||||
{
|
||||
IsEnabled = false;
|
||||
if (targetObject != null)
|
||||
{
|
||||
Destroy(targetObject);
|
||||
}
|
||||
}
|
||||
|
||||
public void LightToggle() {
|
||||
this.targetingLight.gameObject.SetActive(!this.targetingLight.gameObject.activeSelf);
|
||||
}
|
||||
public bool IsLightOn { get { return this.targetingLight.gameObject.activeSelf; } }
|
||||
|
||||
}
|
11
Assets/Scripts/Pistol/PistolComponent.cs.meta
Normal file
11
Assets/Scripts/Pistol/PistolComponent.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a0bc8aa373bfbe44e91f0625324088be
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in New Issue
Block a user