want to move just one clone and not the rest... how?

I have spent the day trying to solve this. I am really new to c# so please excuse the messy code :slight_smile:

I am generating the floor using a loop and want to then be able to click one section of the floor and have it move up (y)

if i use the commented out line they move up, but not smoothly… if i take it back out, the move smoothly but all as one… what am i missing ?

yes i know one is java and one is C# :slight_smile:

ken

Creation of floor script

   var floorSection : GameObject;
     
    var minX : int = -5;
    var maxX : int = 5;
    var minZ : int = -5;
    var maxZ : int = 5;
    var spaceing : float = 20;

function Start()
{


for ( var z : int = minZ; z < maxZ; z++)
	
{

        for ( var x : int = minX; x < maxX; x ++ )
    	{
  			
    		var pos : Vector3 = new Vector3( x , 0, z );
       		var clone : GameObject = Instantiate( floorSection, pos, Quaternion.identity );
       		clone.name = "Wall_" + x.ToString() + "_" + z.ToString();
    		
    	}
}

the movement script

public float smooth;

public float raiseHeight;

public float baseHeight;
	
    private Vector3 newPosition;
	private float currentPositionX;
	private float currentPositionZ;
	public RaycastHit hit;
	
	
	void Awake ()
    {
    	newPosition = transform.position;
		currentPositionX = transform.position.x;
		currentPositionZ = transform.position.z;
		baseHeight = 0;
		raiseHeight = 3;
    }
 
void Update () 
{
    
    //if(Input.GetMouseButtonDown(0) && collider.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hit, Mathf.Infinity)) 
	{
		PositionChanging();
	
	}
	
}		
			
void PositionChanging ()
	{

        Vector3 positionA = new Vector3(currentPositionX, raiseHeight, currentPositionZ);
        Vector3 positionB = new Vector3(currentPositionX, baseHeight, currentPositionZ);
        
        if(Input.GetMouseButtonDown(0))
			{
            newPosition = positionA;
			}
        if(Input.GetMouseButtonDown(1))
			{
            newPosition = positionB;
			}
        transform.position = Vector3.Lerp(transform.position, newPosition, smooth * Time.deltaTime);
	}
}

You can fix your current code by changing the line you commented out as follows:

if(Input.GetMouseButtonDown(0) && collider.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hit, Mathf.Infinity) && hit.transform == transform)

As an alternate, you might take a look at OnMouseDown()