initial commit
This commit is contained in:
32
Assets/Scripts/Lesson_3/ScrollOnHover.cs
Normal file
32
Assets/Scripts/Lesson_3/ScrollOnHover.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class ScrollOnHover : MonoBehaviour
|
||||
{
|
||||
|
||||
void Update()
|
||||
{
|
||||
float scroll = Input.mouseScrollDelta.y;
|
||||
|
||||
|
||||
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
|
||||
if (Physics.Raycast(ray, out RaycastHit hit))
|
||||
{
|
||||
if (hit.collider.gameObject.tag == "LeverParent")
|
||||
{
|
||||
if (scroll == 0) return;
|
||||
StrikerLeverController slc = hit.collider.gameObject.GetComponent<StrikerLeverController>();
|
||||
if (slc != null)
|
||||
{
|
||||
slc.RotateLever(scroll);
|
||||
}
|
||||
}
|
||||
if (hit.collider.gameObject.tag == "FlyButton")
|
||||
{
|
||||
if (Input.GetKeyDown(KeyCode.E) ) {
|
||||
hit.collider.gameObject.GetComponent<RocketButtonController>().Use();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user