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