How can I get position of collider ?

Hey

This is my script

void Update () {
string tagScr;
Item item_scr = null;
Vector3 mousePos;
Vector3 mousePos2;

	GameObject colliderGameObject;
	Vector3 colliderPointion;
	
	if (Input.GetMouseButtonDown (0)) { 
		
		Ray ray = Camera.main.ScreenPointToRay (Input.mousePosition);
		
		
		if (Physics.Raycast (ray, out hit)) {
			
			
			tagScr = hit.collider.tag;
			Debug.Log("tagScr : "+tagScr);

                             colliderGameObject = GameObject.Find(hit.collider.tag);

			colliderPointion = new Vector3(colliderGameObject.transform.position.x,colliderGameObject.transform.position.y,colliderGameObject.transform.position.z);

			
		}
		
	}
}

Hey, @boonsr. You won’t be needing tagStr and colliderGameObject. To get the position of the collider, just set the value of colliderPointion to hit.collider.transform.position.

Here’s the updated version of your Update function:

     void Update()
	{
		Vector3 colliderPointion;

		if( Input.GetMouseButtonDown( 0 ) ) { 

			Ray ray = Camera.main.ScreenPointToRay( Input.mousePosition );
			RaycastHit hit;

			if( Physics.Raycast( ray, out hit ) ) {
				colliderPointion = hit.collider.transform.position;
				Debug.Log( colliderPointion );
			}
		}
	}