Commit 1e35be9b authored by 15박보승's avatar 15박보승

NoteObject가 hit 되었는지 판정하는 isHit 구현

parent 31e9a1e9
......@@ -4,7 +4,8 @@ using UnityEngine;
public class EdgeNoteObject : NoteObject
{
Vector2 direction;
[SerializeField]
private Vector3 direction;
public void Init(HandType hand)
{
Material mat = GetComponent<Renderer>().material;
......@@ -29,4 +30,9 @@ public class EdgeNoteObject : NoteObject
{
transform.position = Vector3.Lerp(endPoint, endPoint + new Vector3(0, 0, 200), remainedTime / maxRemainedTime);
}
public override bool IsHit(Ray ray)
{
return Mathf.Abs(Mathf.Acos(Vector3.Dot(direction.normalized, ray.direction))) < 30;
}
}
\ No newline at end of file
......@@ -83,4 +83,10 @@ public class ForwardNoteObject : NoteObject
color.a = 1f-Mathf.Clamp(remainedTime / maxRemainedTime, 0, 1);
img.color = color;
}
public override bool IsHit(Ray ray)
{
RaycastHit hit;
return GetComponent<Collider>().Raycast(ray, out hit, 40);
}
}
......@@ -45,4 +45,6 @@ public abstract class NoteObject : MonoBehaviour
{
transform.position = endPoint + new Vector3(0, 0, 50) * remainedTime / maxRemainedTime;
}
public abstract bool IsHit(Ray ray);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment