FragMate CommunityLog in

FragMate - Software and Game Developer Community, including Resources, Forums, Marketplace & More.

Share

descriptionSeparate Objects after Mouse Clicking in Unity 5.6.4

more_horiz
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!

descriptionRe: Separate Objects after Mouse Clicking in Unity 5.6.4

more_horiz
Hello Roshan Aravinda,

I'am not an expert myself has I have been using it mainly to do crossplatform aplications. However I felt like I should at least try to help you because I had no help at my final project and it was a pain because of that.
So I will give you the topics that you need to research in order to be able to do this. If you are familiar with C# it will be very easy If not you will have to learn a little bit of object oriented C#.

So before I start. Note that you have to create a gameobject in your scene or attach the script you will create to any of the objects in your scene.
You will need to understand Animators and how its state machine works. You have to create an animation for the 2 objects to move. The way they move will be exacly like you want it to. Because while creating the animation you can record the position of the cube while you move it by drag and drop.

At this point you will have your animation created. Now you should know the easiest way to instatiate an object from the scene is to declare a field of the same time as public in the script. This way you can just drag and drop it on the inspector. Rather than having to search for the objects in your scene.

You will have to use the Mouse click function: https://docs.unity3d.com/ScriptReference/Input.GetMouseButtonDown.html

And the way you animate it on click is that when you press the mousbutton you desire the Animation State will change.
I hope that whit this information you will be able to do it.

I made this menu using the steps described above.



Best regards,
Stephane Carreira

descriptionRe: Separate Objects after Mouse Clicking in Unity 5.6.4

more_horiz
Hello Stephane Carreira,

First of all I would like to thank you for give me the directions to do the right thing. Those days I'm learning animation things and scripting part of unity after your guidelines. After that I'll hope to do an simple animation like your one and I'll post that as you did for me.

Thank You!

descriptionRe: Separate Objects after Mouse Clicking in Unity 5.6.4

more_horiz
Hello Stephane Carreira,

With your guidelines I have tried many and many things to do my animations as well as suite for me. Now it's working perfectly and also I would like to thank you. But still I need to how to smooth this kind of animation. Because my project include engine parts and I have to animate those parts very smoothly for get the attraction. I hope you will help for me and also I've done my part as I promised to you.



Thank You!
Permissions in this forum:
You cannot reply to topics in this forum