-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
한번이라도 써본 적 있는 유용했던 함수 정리
Mathf.Clamp(float xvalue, xmin, xmax)
변수나 오브젝트의 범위를 지정하여 xvalue이 xmin과 xmax 사이에서만 값을 띄게 만들어줍니다.
ex) transform.position = new Vector3(Mathf.Clamp(10, 1.0f, 3.0f), 0, 0);
이 때 반환되는 결과는?
transform.position = (3,0,0)
Quaternion.LookRotation(Vector3 x,y,z)
target x,y,z(인자)를 기준으로 회전합니다.
ex)
Vector3 relativePos = target.position - transform.position;
transform.rotation = Quaternion.LookRotation(relativePos);-> 이게 좀 어렵다. 이번에 체스게임에서 써먹어 보고 싶지만.... 어떤 경우에 쓰게 될까?
세부 참조 ) https://m.blog.naver.com/PostView.naver?isHttpsRedirect=true&blogId=happybaby56&logNo=221324341865
실제 사용 예시 )
if(Physics.Raycast(camera.transform.position, camera.transform.forward, out hitinfo, range)
Instantiate(hit_effect_prefab, hitinfo.point, Quaternion.LookRotation(hitinfo.normal));우리가 총을 쏘고, 총을 맞췄을 때 파티클이 생성되게 하고 싶다. 이 때 파티클은 고유의 회전값이 있을테고 바닥에 맞출땐 파티클이 위로 생성되어 있는 돌에 맞을 땐 위보다는 옆으로 튀기는 파티클이 상식적으로 옳을 것이고, 그럴 때 LookRotation을 사용한다!
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels