• 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
Question by dorpeleg · Jan 20, 2013 at 05:37 PM · rotationitweenpathmoveto

iTween MoveTo + Rotation?

Hello everyone.

I'm using iTween's MoveTo to move my gameobject along a path and everyt$$anonymous$$ng works fine.

My problem is, the rotation of the gameobject stays the same w$$anonymous$$le he is moving along the path.

I want $$anonymous$$m to rotate in the direction of the path.

T$$anonymous$$s is my line of code:

 iTween.MoveTo(gameobject, iTween.Hash("path", iTweenPath.GetPath("MyPath"), "time", 500));

Thanks!

Comment
Czar-Man

People who like this

1 Show 0
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

3 Replies

· Add your reply
  • Sort: 
avatar image

Answer by aliakbo · Jan 20, 2013 at 07:17 PM

As the iTween documentation shows-

You can use the "orienttopath" property to orient to its direction of travel and the "lookahead" property to influence how strict "orienttopath" is and how much the object will anticipate each curve.

"orienttopath" is a boolean so you should set it to true, "lookahead" should be set to a value between 0 and 1 depending on how you want your gameobject to react.

Your final code would look somet$$anonymous$$ng like t$$anonymous$$s-

 iTween.MoveTo(gameobject, iTween.Hash("path", iTweenPath.GetPath("MyPath"), 
      "orienttopath", true, "lookahead", .5f, "time", 500));

 


Comment
Chandni

People who like this

1 Show 5 · 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 dorpeleg · Jan 20, 2013 at 07:38 PM 0
Share

I added the values you said but it still wont rotate. By looking at the rotation of the object while its moving, I do see it change but very very little, so its hardly noticeable. I even triad it with lookahead set to 1 but still nothing.

avatar image aliakbo · Jan 20, 2013 at 07:43 PM 0
Share

Apparently I somehow missed "looktime" in my answer above, set "looktime" to a small number and see how it works out.

avatar image dorpeleg · Jan 20, 2013 at 07:53 PM 1
Share

I added the "looktime" with a value of 0.01 Now the object is facing a totally different direction but still not rotating along the path.

avatar image dorpeleg · Jan 21, 2013 at 08:17 PM 1
Share

Any help with this?

avatar image saliakbari6603 · Dec 09, 2018 at 10:45 AM 0
Share

this not work for me :/

avatar image

Answer by shra12ddha · Sep 05, 2015 at 03:14 PM

You can use iTween : iTween.MoveTo(gameObject, iTween.Hash("path", iTweenPath.GetPath("New Path 1"), "time", 50, "orienttopath", true));

By t$$anonymous$$s line of code your object will follow the path and will run along that path only.

Comment

People who like this

0 Show 1 · 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 vanshika1012 · Sep 20, 2015 at 07:44 AM 0
Share

Hi,

I am creating a 2d game, in which a sprite is following some random path. I have successfully completed the following thing but my gameobject is not rotating according to the path. I am using itweenpath. Any help?

avatar image

Answer by saliakbari6603 · Dec 09, 2018 at 10:34 AM

if you use 2D project: replace itween class with iTween.txt in attach. and change or add :

  void Awake()
         {
             iTween.dimensionMode = iTween.DimensionMode.mode2D;
         }

enjoy :)


itween.txt (332.9 kB)
Comment

People who like this

0 Show 1 · 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 lolaswift · Dec 05, 2021 at 03:14 PM 0
Share

@saliakbari6603 iTween.dimensionMode doesn't exist anymore. Any idea how to replace it? many thx.

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

16 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

Related Questions

iTweens MoveTo and "path" property 7 Answers

itween path restrict rotation on TWO axis 0 Answers

iTween Camera Jitter while moving on path 2 Answers

itween path , orient to path...plane rotation 0 Answers

iTween Path 2D rotation, orientToPath issue. 1 Answer


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