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 /
avatar image
0
Question by sandeep-maiya · Jul 08, 2017 at 12:46 PM · scripting problemmovement scriptcodepagexyz

Script to Move different parts of Gantry robot in X,Y,Z axis in sequence

Hello Everyone, I am very new to programming. I am trying to do x,y, z movement of different parts of a Gantry robot in sequence in a single program but till now i have not succeeded. Can anyone help me in writing code to move different parts of a single object in X,Y,Z axis in sequence in a single c# program. Any help is highly appreciated.

Comment
Add comment · Show 2
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 Bunny83 · Jul 09, 2017 at 08:14 AM 0
Share

Your question contains very little information about your actual robot. Just to clear the first uncertainty: Do you talk about a virtual 3d model of such a robot inside of your Unity project, or do you mean an actual real robot which you want to control from Unity? Hopefully you mean the first one.

As the others have mentioned in their answers having a single object with multiple parts contradicts each other. If you have multiple parts it can't be a single object.

It would help to have some more information about your robot:

  • A screenshot / image would help

  • A screenshot of the hierarchy (fully expanded) of the robot object would also be great.

avatar image sandeep-maiya · Jul 09, 2017 at 09:58 AM 0
Share

Thanks a lot for your reply...To be more clear i have attached the photo of Gantry robot. Here, the part which is red has to move horizontally and the part which is black has to move horizontally and vertically (basically it's a pick and place robot). Can i script multiple motions in sequence in a single script? If yes, can you please guide me. (because i have succeeded in moving single motion at a time but not multiple motions operating one after the other)

gantry.png (33.0 kB)

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Shippety · Jul 09, 2017 at 01:13 AM

Hey! I couldn't completely tell based on what you said, did you mean there are different objects that are part of the same object you're trying to move, or didja just mean you were trying to move on the different axis?

An easy way to move something on a single axis is just to use Transform.Translate() like this:

 transform.Translate(Vector3.forward * Time.deltaTime);

If you want to move different objects different ways in the same script, just substitute whichever object.transform for 'transform' in the Translate code.

To control which axis / direction the object is translating, change 'Vector3.forward' to something else. Look under the static variables list here and you can see which term you'd like to use based on the axis you wanna change.

Hope that's helpful! If something doesn't make sense or I wasn't clear just tell me :)

Comment
Add comment · Share
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
0

Answer by Jwizard93 · Jul 09, 2017 at 01:57 AM

Shippety's advice is probably the best way to move the robot. I read your question as though you want each movement in one axis to complete before moving in the next. There are many ways to do this.

Detecting if something made it to a certain point can be frustrating because unity isn't so picky about precise positioning. For example if you say move to the right unitl transform.position.x == 5 it may never stop moving. why? Because it is very unlikely that it's position will be exactly 5 on any frame. You could use > and < instead but now you have to write it essentially twice to handle movement in the positive and negative directions.

You will probably end up doing this if you really must have it in one script.

Personally I'm dreaming up a system of colliders you instantiate at desired positions.

Thes colliders have a variable which is set upon their instantiation telling them which "waypoint" they are. They have script attached which uses OnTriggerEnter function to send the gantry arm on to the next waypoint.

This is just one of a thousand ways you can do this.

Comment
Add comment · Share
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

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

108 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 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 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 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 to I put a speed limit on my character's movement? 1 Answer

How do I make a Mobile touch screen joystick for my PLayer in 2D platformer? 0 Answers

Help with making script efficient 3 Answers

Why wont my character stop moving when it collides with the obstacles?,Why doesn't my movement script stop? 0 Answers

How to move and rotate object over slanting surfaces and still keep object's y axis perpendicular to the surface normals? 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