I have a gameobject that have a rock mesh. However, the bottom of the mesh is hallow and ugly. I want to place it on a mesh that looks like a hill, so that the player cannot see the gameobject’s ugly and hallow bottom.
I have a script that uses raycast to place the rock. The raycast is above the mesh. When I raycast downwards, I get a Vector3 on the hill looking mesh. I place that rock on that point, and I can see its bottom! How to avoid that using C# code?
Here is my full question:
Rotate and move a GameObject, which have a “mesh” as its component, so that it sits on another mesh “perfectly” without seeing the GameObject’s bottom through c# script in Unity.
Here are some Images:
Here is the code I use to place it on the mesh, and it works just fine!
Vector3 pointFromAbove = new Vector3(Random…);
if (Physics.Raycast(pointFromAbove, Vector3.down, out hit))
GameObject newObject = (GameObject)Instantiate(prefab, hit.point, Quaternion.identity, parent);
... ... }