BeatSaber 게임 모작 및 이그노어등
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
using System.ComponentModel.Design.Serialization;
|
||||
using UnityEngine;
|
||||
|
||||
public class Saber : MonoBehaviour
|
||||
{
|
||||
|
||||
public LayerMask layer;
|
||||
Vector3 prevPos;
|
||||
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
RaycastHit hit;
|
||||
|
||||
if(Physics.Raycast(transform.position, transform.forward, out hit, 1, layer))
|
||||
//Raycast는 위치값을 받는 클래스로 뒤의 인수는 위치, 방향, 저장되는 변수, 거리, layer에 해당되는것만
|
||||
{
|
||||
Vector3 v1 = transform.position - prevPos; // 현재위치 - 이전 위치 = 이동방향
|
||||
|
||||
if(Vector3.Angle(v1, hit.transform.up) > 130)
|
||||
//두 벡터 사이의 벌어진 각도를 구하는 함수 이동방향v1과 충돌한 물체의 위쪽방향
|
||||
{
|
||||
Destroy(hit.transform.gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
prevPos = transform.position;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user