Home > front end >  How can I spawn an object on the opposite side of mesh(wall) I'm clicking on in unity3d?
How can I spawn an object on the opposite side of mesh(wall) I'm clicking on in unity3d?

Time:07-19

I'm new to unity and I'm using unity3d. So if I'm clicking on a mesh, for example a wall. I want to spawn an object on the opposite side of the wall I'm clicking on. It should work on x,y,& z axis.

CodePudding user response:

You can simply draw a vector from where you are to the wall (wallPosition) - (YourPosition). Normalizing this vector will give you the direction you need to go to be on the other side of the wall. By knowing the direction then based on the thickness of the wall, its position, and ground position you can calculate the new position for your object.

  • Related