HOW CAN I MAKE OBJECT MOVE WHEN IT IS TOUCHED AND STOP ON COLLISION AND COME BACK TO ITS ORIGINAL PLACE WHEN IT IS TOUCHED AGAIN?
Hi I am new to unity and was trying to create a game for android and I know little about programming(C#),and I wanted my object(say key) to move when it is touched and stop when it collides with my second object (say lock) and I also wanted it to come back to its original position if it is touched after the collision.THANK YOU.
You should begin by going through the tutorials in the Learn link at the top.
Thank you Dave Carlile for your suggestion, but the reason why I posted this question is that I was expecting that someone with much more experience and knowledge would help me out with the scripting. I have gone through some tutorials but I could not find anything that was so useful. Anyway thank you once again for your response.
People here are happy to help you, but most aren't going to write your code for you. Is there something specific you're having trouble with? If you have no idea what to do then I would approach it by first identifying the various parts of the problem:
How do I make an object move
How do I detect when an object is touched/clicked
How can an object detect a collision
How can I execute code when an object collides with something
Start with that first item and make a program in Unity that can do just that. Don't just copy code from somewhere, think about how it works. Every little piece you learn like that you can apply to future problems. Once you can do that, move on to the next piece. Do it completely separately from the first problem to start with. $$anonymous$$ake something that can detect when it's clicked on, and just write out a Debug.Log message.
Once you can do both of those things you can figure out how to combine them.
Edit: All of these things can be figured out from the Unity manual, or from the tutorial videos in the Learning area.
Your answer
Follow this Question
Related Questions
How can I get the player to face the direction it is going in a Unity 2D Game? 0 Answers
Movement input problem? 1 Answer
I can't seem to rotate my character depending on what side he is running to (2D sidescroller) 0 Answers
What is wrong with this script? 3 Answers
Object Won't move down on y axis until It moves up on the y axis or on any way of x axis 0 Answers