Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class PlaceTurret : MonoBehaviour
- {
- private int tileLocationX;
- private int tileLocationZ;
- [SerializeField] int minTileX;
- [SerializeField] int maxTileX;
- [SerializeField] int minTileY;
- [SerializeField] int maxTileY;
- // Start is called before the first frame update
- void Start()
- {
- tileLocationX = Random.Range( minTileX, maxTileX );
- tileLocationZ = Random.Range( minTileY, maxTileY );
- //Debug.Log( "Trying to find floor: " + tileLocationX + ", " + tileLocationZ );
- Vector3 newPos = new Vector3( tileLocationX, 30, tileLocationZ );
- RaycastHit hit;
- Debug.DrawRay( newPos, Vector3.down * 100, Color.white, 5 );
- if( Physics.Raycast( newPos, Vector3.down, out hit, 100 ) )
- {
- //Debug.Log( "Hit ground" );
- newPos.Set( newPos.x, hit.point.y, newPos.z );
- //transform.Translate( 0, hit.point.y, 0 );
- }
- //Debug.Log( newPos );
- transform.Translate( newPos,Space.World );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement