Separate Objects after Mouse Clicking in Unity 5.6.4

Dear Friends,

I’m Roshan Aravinda who is a student in University of Vocational Technology, Sri Lanka. In these days I’m trying to develop my final project with unity and therefore my project is model the Toyota hybrid vehicle inverted converter with 3D Max and Unity.

After watching few videos on youtube I had collect basic knowledge of unity and their assets. So I would like thanks for video makers who are guide me to this website.

However, in most videos explain create games and environments. But my problem is mostly different from games and environments. So I would like to explain my matter.

I need to know what is the way to separate few objects after a mouse click and also reattach the objects after doing the same click again. As an example assume there are two cubes and already a one cube inside in another cube. After a mouse click I need to show those cubes separately, but this animation must be smooth (Using Ease In/Out Animation) and I need to do it in professional way. (Refer the attachment)

According to my knowledge I know I have to use C# Programming Language and Codes to do this operations. But I didn’t no how to setup the unity environment, because I’m a newcomer for this application.

So, If anyone can explain this matter and help me I appreciate it very much and more. Already I have lot of questions and problems about unity and I will like share those things with this forums.

Thank You!

You can move your object using Vector3.Lerp, and manage the clic using a boolean, something like that on update function :

bool alreadyCliced = false

if(Input.GetMouseButtonDown(0)) //The mouse clic
{
  if(!alreadyCliced)
     alreadyCliced = true;
    //Moove an Object using Lerp and position hardcoding to simplify
  else
    alreadyCliced = false;
    //Moove an Object using Lerp and initial position save in the GameObject
}

You can manage which object as been clicked using OnMouseOver() and Collider

Good luck for your project