Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice
  2. Ever participated in one our Game Jams? Want pointers on your project? Our Evangelists will be available on Friday to give feedback. Come share your games with us!
    Dismiss Notice

How to change the orientation for an overlapbox?

Discussion in 'Physics' started by Norvegat147, Sep 16, 2019.

  1. Norvegat147

    Norvegat147

    Joined:
    Nov 5, 2016
    Posts:
    15
    Hi there, after a good amount of searching I haven't been able to find out how to change the rotation of my overlap boxes set up.
    Code (CSharp):
    1. //draw a hitbox in front of the character to see which objects it collides with
    2. Vector3 boxPosition = transform.position + (Vector3.up * lastAttack.collHeight) + Vector3.right * lastAttack.collDistance;
    3. Vector3 boxSize = new Vector3 (lastAttack.CollSize/2, lastAttack.CollSize/2, hitZRange/2);
    4. Collider[] hitColliders = Physics.OverlapBox(boxPosition, boxSize, transform.rotation, HitLayerMask);
    I'm using it for damage calculation. I want the OverlapBox to take the same rotation of the player and always be in front of the player.
     
unityunity