• 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
1
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 everything works fine.

My problem is, the rotation of the gameobject stays the same while he is moving along the path.

I want him to rotate in the direction of the path.

This is my line of code:

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

Thanks!

Comment
Add comment
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
1

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 something like this-

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

 


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

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 this line of code your object will follow the path and will run along that path only.

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

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
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.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

15 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

Related Questions

Go back to first node (itween + moveto) 2 Answers

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, moving to a node on a path. 1 Answer

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges