Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
0
Question by yade123 · Sep 23, 2015 at 01:25 PM · c#movement script

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.

Comment
Add comment · Show 3
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Dave-Carlile · Sep 23, 2015 at 01:27 PM 0
Share

You should begin by going through the tutorials in the Learn link at the top.

avatar image yade123 · Sep 23, 2015 at 04:05 PM 0
Share

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.

avatar image Dave-Carlile · Sep 23, 2015 at 04:31 PM 1
Share

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.

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

29 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

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


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges