Placing objects in the world
We've done most of the groundwork for placing the objects in the world. We already have a method for detecting a plane and providing a visual indicator for the player, so they know what a suitable surface is and, more importantly, what isn't. Now we need to spawn an object when a player taps on the screen and there is a valid plane. To do this, we need to create a new script, as follows:
- Create a new script called
PlaceObjectOnPlane
:public class PlaceObjectOnPlane : MonoBehaviour { Â Â Â Â public GameObject ObjectToPlace; Â Â Â Â private FindPlane PlaneFinder; Â Â Â Â private PlaneData Plane = null; Â Â Â Â void Awake() Â Â Â Â { Â Â Â Â Â Â Â Â PlaneFinder = FindObjectOfType<FindPlane>(); Â Â Â Â } Â Â Â Â void LateUpdate() Â Â Â Â { Â Â Â Â Â Â &...