Search Unity

  1. We are migrating the Unity Forums to Unity Discussions by the end of July. Read our announcement for more information and let us know if you have any questions.
    Dismiss Notice
  2. Dismiss Notice

Question Physics.Overlapbox 3D

Discussion in 'Physics' started by applisations, Jan 23, 2024.

  1. applisations

    applisations

    Joined:
    Oct 11, 2023
    Posts:
    11
    Hello,
    I wanted to ask if it is possible to adapt the Physics.overlapbox to the box collider of a game object? The background is that I have a game character in my project that swings an axe and is supposed to hit a tree with it. With each hit, the tree should be damaged until it falls over. Now I'm wondering if it's not possible to simply attach an invisible cube to my axe and somehow say that this cube is the overlapbox. And every time an object called a tree enters the overlapbox, the tree receives damage?
    Would be really grateful for help.
     
  2. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,700
    Are you aware that Physics.OverlapBox is just that, you're just asking what this "invisible box" overlaps. You don't need to attach anything to use it.

    Maybe you're indirectly asking how to visualise the arguments you pass to OverlapBox but that's not really a physics question.

    You can use Gizmos.DrawCube to visualise the position, size, rotation properties on your script of a virtual box.
     
    applisations likes this.