Unity3D/Problems
ParticleSystem 3D Start Rotation
일등하이
2016. 8. 19. 13:41
반응형
Unity 5.x 에서 파티클 시스템에서 3D Start Rotation이라는 속성이 추가됨
총
- 총구
- 총알 이펙트 (Particle System)
총의 각도가 변할때 총알 이펙트의 3D Start Rotation값을 함께 마춰 줘야 함
이때 파티클의 Simulation Space 를 World로 설정
using UnityEngine;
using System.Collections;
public class TestRifleFireEffect : MonoBehaviour {
public ParticleSystem bullet;
void Update()
{
var dir = (this.transform.eulerAngles.y > 180) ? -1 : 1;
var angleY = (dir > 0) ? this.transform.eulerAngles.y : (360 - this.transform.eulerAngles.y) * dir;
var radian = (Mathf.PI / 180) * angleY;
bullet.startRotation3D = new Vector3(0, radian, 0);
}
}
1. 총의 오일러 각도의 Y값을 구함
2. 방향을 계산 (180 ~ 360 = -1 , 0 ~ 180 = 1 )
3. 각도를 라디안으로 변환
4. 적용
간단한거일지 몰라도 급하게 하려면 생각이 잘 안나서 끄적여봄
http://www.rapidtables.com/convert/number/degrees-to-radians.htm
반응형