- Home /
Question by
WarOnGravity · Nov 24, 2018 at 12:51 PM ·
orientationquaternionsquaternion.lookrotationroation
Boxcast Rotaion/ Orientation Help
How do you make a boxcast rotate and remain orientated to it's parent game object? This is my code:
float m_MaxDistance;
Collider m_Collider;
bool m_HitDetect;
RaycastHit m_Hit;
void Start() { m_MaxDistance = 144.0f; }
void FixedUpdate(){
m_HitDetect = Physics.BoxCast(m_Collider.bounds.center, new Vector3(transform.localScale.x / 2, transform.localScale.y / 2, 0.5f), transform.forward, out m_Hit, Quaternion.LookRotation(transform.forward), m_MaxDistance);
}
Thanks
Comment
Answer by hexagonius · Nov 24, 2018 at 01:19 PM
You don't need to create a rotation from the transform's forward vector. Just use its rotation directly.