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

$$anonymous$$ore 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 ins$$anonymous$$d 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

· Add your reply
  • Sort: 

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

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

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

Does iTweenpath support OnTriggerEnter? 2 Answers

iTween Get the path from object nodes and move the object at same speed by loop 1 Answer

How to make Animation and Physics work together? 2 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