Need to Update the position

I changed the Position with OnMouseDown, If I want to change the position to its old place how can I do it? I want the carton box to place inside the container when I tap the left mouse button, and I want that carton box to go to its old position when I tap the mouse button again. Can you help me solve this?I am attaching a screenshot below.



Simple. Before you move it the first time, store it’s position in a variable. Then, when you want to move it back, use that variable to determine where it needs to go.

1 Like

Yes, I stored it in a variable, but I want the start position only when it reached the destination position, all these should change only when I press the left mouse button.

7884826--1003246--UpdatedCode.png

Well, you have a start position. And you know where you want the second position. Then in onMouseDown, you need some way to verify what position it’s at. A simple bool will handle 2 positions. So, first click, check your bool, if it’s a certain value, set it to the second position, change your bool value. Second click, check your bool which is now the other value, so you set it back to the start position and change your bool value. That can handle a simple back and forth method on click. If you need more places to move to, then you’ll need to track using an int and a collection of vector3.