• 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 LPTFabio · May 27, 2017 at 02:31 PM · animationunity 5script.itweenitweenpath

Itween 180º curve position and rotation problem

I am trying to create a simple mobile game where my character is following a certain path (using ItweenPath) there is a point in the path where he have a 180º curve, so it should end up upside down (the camera is a child of the character so it will do everything exactly the same) BUT the itweenPath is making the character rotate 180º on Y axis that is a problem for me because if he does that, the right and left arrow keys are now, respectively, left and right i will past some code

Character has 9 paths in a 3x3 grid style where he can change between them to avoid objects or to pick up some

         void Start () {
             //Adicionar propriedades aos caminhos
             iTween.Hash("path", iTweenPath.GetPath("MidPath"), "time",tempoTotal ,"orienttopath", true, "easetype", iTween.EaseType.linear );    
             iTween.Hash("path", iTweenPath.GetPath("LeftPath"), "time",tempoTotal ,"orienttopath", true, "easetype", iTween.EaseType.linear);    
             iTween.Hash("path", iTweenPath.GetPath("RightPath"), "time",tempoTotal ,"orienttopath", true,  "easetype", iTween.EaseType.linear);
             iTween.Hash("path", iTweenPath.GetPath("UpMidPath"), "time",tempoTotal ,"orienttopath", true,  "easetype", iTween.EaseType.linear);    
             iTween.Hash("path", iTweenPath.GetPath("UpLeftPath"), "time",tempoTotal ,"orienttopath", true,  "easetype", iTween.EaseType.linear);    
             iTween.Hash("path", iTweenPath.GetPath("UpRightPath"), "time",tempoTotal ,"orienttopath", true,  "easetype", iTween.EaseType.linear);
             iTween.Hash("path", iTweenPath.GetPath("DownMidPath"), "time",tempoTotal ,"orienttopath", true,  "easetype", iTween.EaseType.linear);    
             iTween.Hash("path", iTweenPath.GetPath("DownLeftPath"), "time",tempoTotal ,"orienttopath", true,  "easetype", iTween.EaseType.linear);    
             iTween.Hash("path", iTweenPath.GetPath("DownRightPath"), "time",tempoTotal ,"orienttopath", true,  "easetype", iTween.EaseType.linear);
             //Caminhos em array
             pathM = iTweenPath.GetPath ("MidPath");
             pathL = iTweenPath.GetPath ("LeftPath");
             pathR = iTweenPath.GetPath ("RightPath");
             pathUM = iTweenPath.GetPath ("UpMidPath");
             pathUL = iTweenPath.GetPath ("UpLeftPath");
             pathUR = iTweenPath.GetPath ("UpRightPath");
             pathDM = iTweenPath.GetPath ("DownMidPath");
             pathDL = iTweenPath.GetPath ("DownLeftPath");
             pathDR = iTweenPath.GetPath ("DownRightPath");
             strPath = "mid";
             currPath = pathM;
         }//fim do Start

I use PutOnPath + LookUpdate to move and rotate/point the object into the path so the player knows where he is going i didnt used MoveTo because i cant change between paths with MoveTo (or atleast i dont know how)

 countTime += Time.deltaTime; //Tempo
     percent = (countTime / tempoTotal)-0.001f;
     futurePercent =((tempoTroca+countTime) / tempoTotal)-0.001f; 
     futureRotate =(countTime / tempoTotal)+0.201f;
     possible=false;
 
     if (Input.GetKeyDown(KeyCode.LeftArrow)) {
         if (strPath == "right") {
             possible = true;
             currPath = pathM;
             strPath = "mid";
             stuff = iTween.PointOnPath(iTweenPath.GetPath("MidPath"), futurePercent);

}

Comment

People who like this

0 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 LPTFabio · May 25, 2017 at 05:56 PM 0
Share

More info: so far test didn't helped my solving but new info here: i am going to past the code where i think the problem is:

  if (move == true && countTime >= timeFixed-(tempoTroca/2)) {
          stuff = iTween.PointOnPath(currPath, futureRotate);
          iTween.LookTo (gameObject, iTween.Hash("looktarget", stuff, "time", tempoTroca/2));
 
 
      }
      if (move == false || countTime > timeFixed) {
          move = false;
          iTween.LookUpdate (gameObject, iTween.Hash("axis", "x","looktarget", stuff, "time", lookTime));
 
          if (countTime <= tempoTotal)
          iTween.PutOnPath (gameObject, currPath, percent);
          stuff = iTween.PointOnPath(currPath, futureRotate);
 
      }

The problem is probably on: "iTween.LookTo" or "iTweenLookUpdate" when i disable the rotation in the on LookUpdate he stops rotating BUT the camera rotates instead so i am no longer looking forward

some explanation code: the first if its when i change paths i look to the target path, the second if is to look forward the current path

ANOTHER strange thing for me: if i put ("axis", "y") the Y will still rotate but X wont, and if i put "Z" it wont rotate on any axis, if i put X it wont rotate on X and Y, that is rather confusing for me ..

avatar image LPTFabio · May 25, 2017 at 06:01 PM 0
Share

I did a quick fix WHICH is not Optimal but basicly since when teh object turns aroudn 180º making the right/left and Up/Down paths be Opposite i switched the last 2 node (before teh problem appearing) to the opposite sides so now in last 2 nodes the right path is named left etc .. (i hope you get) something strange about that is: The Y Rotation happens EXACTLY on the Crossing of paths o i am thinking that maybe the ITweenPath (the visual) its rotation (by itself since i dont have or dont know how to rotate ItweenPath script on visual editor) i am to leave for today i hope someone comes up with some ideas or test for me to try out

0 Replies

  • Sort: 

Unity Answers is in Read-Only mode

Unity Answers content will be migrated to a new Community platform and we are aiming to launch a public beta by June 9. Please note, Unity Answers is now in read-only so we can prepare for the final data migration.

For more information and updates, please read our full announcement thread in the Unity Forum.

Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

How can I save an iTween animation as a .anim file? 1 Answer

Animation not working correctly 0 Answers

Instantiate an object around the player following a path built with iTween asset 0 Answers

Issue with changing the name of iTween.Path() at runtime 0 Answers

iTween Get the path from object nodes and move the object at same speed by loop 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