Tower Defense Question

How would one go about utilizing a script to efficently place an object (in this case, a tower mesh) on a ground or terrain surface?

Logically, I would think something like this (assuming you’re using mouse input):

  1. Raycast from mouse position to your terrain surface (Physics.Raycast)

  2. Get the normal of that surface (RaycastHit.normal)

  3. Instantiate whichever tower object you want at raycast’s hit point, aligned with the surface normal

    var ray = Camera.main.ScreenPointToRay (Input.mousePosition);
    var hit : RaycastHit;
    var hitNorm: Vector3;

    if (Physics.Raycast (ray, hit)) {

     hitNorm = hit.normal;


Additionally, have you looked at the other tower defense questions on this site? There are lots of them for inspiration. If you’re still lost as to how to implement this, try some tutorials. Hope this helps!