hi, currently working on small puzzle type game, we have one square object with four arrow texture, what i want when i click on left arrow my object move to left side, so on… so i set up im object as shown in the following image…
attach MovementScript to my Player as shown in image…
my MovementScript code is as follows…
function Update () {
if (Input.GetMouseButtonDown(0)){
var hit: RaycastHit2D = Physics2D.Raycast(Camera.main.ScreenToWorldPoint(Input.mousePosition), Vector2.zero);
if (hit.collider){
if (hit.collider.tag == “up”){
Debug.Log(“hit up”);
rigidbody2D.velocity = Vector2(0,1);
}
if (hit.collider.tag == “down”){
Debug.Log(“hit down”);
rigidbody2D.velocity = Vector2(0,-1);
}
if (hit.collider.tag == “right”){
Debug.Log(“hit right”);
rigidbody2D.velocity = Vector2(1,0);
}
if (hit.collider.tag == “left”){
Debug.Log(“hit left”);
rigidbody2D.velocity = Vector2(-1,0);
}
}
}
}
every this works perfectly till here,
but when i duplicated the player object, Now if i click left arrow of one object both player is moving left side, I want only selected player should move.

