Translate more than one object on update with the same function
Hi,
I wanna add translate on some GameObjects, but with my code, when one object start to move, the last one stop.
How do i make the previous object keep the move?
My code:
void Update () {
MoveGameObject (Draggable.objectClicked);
}
void MoveGameObject(string objectClickedToMove) {
GameObject objectToMove = GameObject.Find (objectClickedToMove);
if (moveable) {
directions = Draggable.positionOnMouseDown - Draggable.positionOnMouseUp;
if (directions < 0) {
objectToMove.transform.Translate (Vector3.right * moveSpeed * Time.deltaTime);
} else if (directions > 0) {
objectToMove.transform.Translate (Vector3.left * moveSpeed * Time.deltaTime);
}
}
}
Comment
Your answer
Follow this Question
Related Questions
Vector move based on screen size 0 Answers
"transform.Translate" doesn't works 2 Answers
What is the difference between translate and position 1 Answer
Perspective camera touch movement 2 Answers