Instantiating GameObject On The Surface Of Another GameObject On Tap

Hi,

I’m working on an Android application in Unity and I want to be able to instantiate a 3D object (such as a sphere) on the surface of another 3D model. The object should be attached to the models surface where the user has tapped. How would I go about this?

To sum up. This is the behaviour I want:

1: 3D Model.
2: User taps on model.
3: Sphere attaches itself to model at location of tap.
4: When model rotates (X, Y, and Z) attached spheres rotate with it.

I can instantiate a sphere on the model on tap as a child object but I can’t work out how to get the object to instantiate on the surface of the 3D model/mesh.

I have my 3D model inside an empty GameObject so I can change its pivot point and use a box collider for input if that helps. The empty object is rotated to turn the model instead of the model itself.

use raycast, to get tap location (and surface normal direction) on the 3d models mesh collider

then can instantiate object on that hit point, and align to surface

2 Likes

Thanks, all working now.