Good night! I am trying to instantiate a menu for my tower, but it is being placed down the tower. I want exactly placed on the middle of the tower. Does anyone can help me out?
void Update()
{
ray = Camera.main.ScreenToWorldPoint( Input.mousePosition );
hit = Physics2D.Raycast( ray, Vector2.zero, Mathf.Infinity );
if( Input.GetMouseButtonDown( 0 ) )
{
if( hit.collider != null )
{
//Pass the name of the collider's object to be instantiated.
createTowerMenu( hit.transform.name, hit.transform.position );
}
}
}
Inside the method createTowerMenu I instantiate the menu like this:
Instantiate( towerMenu, position, Quaternion.identity );
towerMenu is my prefab and position is hit.transform,position.
