Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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
2
Question by valdelievre · Aug 22, 2012 at 01:50 PM · 2ditweenpathorienttopath

[SCREENSHOTS] itween Path, orientToPath and gameObject rotation, 2D game

Hello community

I have a plane, and a texture attached to it ( Spaceship ). This spaceship has a "direction". I have built a path, via Itween Path through the Editor and applied Itween.MoveTo function at Start() :

 void Start() {
  iTween.MoveTo(gameObject, iTween.Hash("path", iTweenPath.GetPath("spaceshipPath"), "axis", "z", "time", 20, "orienttopath", true)); 
 
 }

My spaceship follow the path properly. However, I thought that with orienttopath=true parameter, it would rotate automatically according to the curve, but it does not rotate at all.

I have tried to set the axis to x or y, but i have a weird behavior, rotating the spaceship to any direction.

In my point of view, the rotation axis should be 'x' though. I have also played with looktime and lookahead parameter, but no luck.

Do you think it is feasible to achieve what i want using only itween.MoveTo in the Start() ?

I guess it would be possible to play around Itween.MoveUpdate + LookAtTarget in the Update() function. LookAtTarget would be the direction vector, calculated in the FixedUpdate() ( target = new position - old position ) but not sure either.

Spaceship starts from here : alt text

Then, it gets here : alt text

I would expect to have something like : alt text

The spaceship is just a plane with a texture using transparent shader attached to it.

Any help would be greatly appreciated

Thanks

Florent

Comment
Add comment · Show 1
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 EasyPlay · Apr 08, 2014 at 09:28 AM 0
Share

I meet the question as valdelievre,can any one show the project with simple example,thanks great.

3 Replies

· Add your reply
  • Sort: 
avatar image
3
Best Answer

Answer by BLarentis · Aug 23, 2012 at 03:33 PM

Ok, got this. What you will have to do is 3 things:

1- Remove the Hash item "axis","z".

2 - Create an empty Game Object and rotate him, so his Axis Z, will be the front of the space ship. As an example, I created a plane with an arrow texture. For it to become with the arrow up, I needed to rotate it 90 in X, and 180 in Y. The empty Game Object I rotate it to 270 in X and 270 in Y. S o the blue arrow(Z axis) of the empty Game Object faced the same direction of my plane arrow.

3- Put your space ship as a child of this empty Game Object. And put the spaceship position on 0,0,0 after. So the center of the spaceship will become the position of his parent, the empty Game Object.

Take care!

Comment
Add comment · Show 3 · 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 valdelievre · Aug 23, 2012 at 08:52 PM 0
Share

Thank you so much, after some tweeking, it works as expected. Thank you guys !

avatar image Igor Pchelko · Dec 11, 2012 at 08:00 AM 0
Share

valdelievre, can you share you tweeks/)solution? thanks.

avatar image Lumbearjack · May 28, 2013 at 07:04 PM 0
Share

I'm having the same issue. I'm trying to have a 2d ship follow the path while only rotating on one axis. So the ship points the direction is should go but not twist about like a ballerina on mescaline. The problem is, I can't find any answers with the exception of this one, though I can't for the life of figure out how this can fix the issue.

From my understanding, the instructions here say to place my ship at 0,0,0, then create an empty GameObject with the same orientation and position as my ship, then place the ship within the GameObject, and move my ship that it is looking toward the empty gameobject's center. This then forces the ship to lock at my desired orientation.

$$anonymous$$aybe I'm not understanding what is being written in step 2, it's hard to visualize. I just can't seem to work out how the parent object's existence can affect the path code in anyway. I'd like to see valdelievre's solution. Or maybe see a visual step by step, if possible.

avatar image
0

Answer by brunopava · Aug 23, 2012 at 03:55 PM

You should try to put your space ship inside a empty game object with it's Z axis facing towards were you want to go(in that case, right). Then you use iTween path on the new object.

Let me know if it works.

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 Iceo MK · Feb 02, 2014 at 12:53 PM

Hello there. I'm having the same problem as the above, but I'm using a 3D object (a cube to represent a mine-cart) and I want it to follow the train tracks path (drawn out using the iTween path system.

The problem is that the cart doesn't rotate (I think the rotation has to be on the Y axis for me since it's in 1st person view). Though I'm not sure how to go about coding that or setting it up. I read the answer above, I already had an empty game object, and the Z Axis (blue arrow) is pointing towards the "face/front" of the cart. It's still not working, and the cart doesn't rotate at all. It just moves along the path (in a funky unstable way if I may add).

Thanks.

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

13 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

Related Questions

Using Itween with Unity 2D, sprite flips over while using orienttopath 1 Answer

ITween orienttopath x-y-z? 1 Answer

iTween.MoveBy in 2D 1 Answer

iTween Path 2D rotation, orientToPath issue. 1 Answer

Path Controlled Character and Working With Physics on iTween 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