Search Unity

Move pivot of object dynamically based on closest point to nearest mesh

Discussion in 'Scripting' started by adamTim, Dec 12, 2021.

  1. adamTim

    adamTim

    Joined:
    Oct 18, 2020
    Posts:
    29
    Hi I'm currently struggling to figure out how to approach this problem. Basically, the player has the ability to duplicate or cut objects from the world and instantiate them elsewhere. The issue happens with collision checking whereas the new spawned mesh is spawned inside another one, instead of being spawned on it/touching it. I figured out this must have something to do with the pivot point location within the mesh, but I'm no sure of how to implement the fix, I tried googling some solutions but none of the existing ones seemed to work or help this case.