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 /
  • Help Room /
avatar image
0
Question by eitanwass · Aug 27, 2016 at 08:48 AM · arraypluginwalkingtweenpaths

Itween paths and generating nodes won't work. please help

Hello human beings!

I am trying to use Itween Paths to "record" the position of the player in some given times and then create a cube that will run through the recorded positions.

Currently i am able to record the positions of the player and copy them to another Itween paths code on the cube but i have ran into some problems i hope you might be able to help me:

  1. The positions of the player are being recorded only if the Game object the records them is selected in the hierarchy.

  2. The cube won't go through the points or even move.

CODE:

Recording script:

 void UpdateActions(){                                            //Being called every 0.25 seconds.
         if (canRecord) {
             if(timePassed != 0){
                 walkingPath.nodeCount = (int)(timePassed / recordingDistance) + 1;
                 walkingPath.nodes [walkingPath.nodeCount - 1] = player.transform.position;
             }
 
             timePassed += recordingDistance;
         }
     }

Walking script:

 void Update () {
         iTween.MoveTo(gameObject, iTween.Hash(
             "path", iTweenPath.GetPath("myWalkingPath"),
             "time", 5, 
             "orienttopath", true));
     }

If you can help me that would be great. tx

Ethan

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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by dhore · Aug 27, 2016 at 01:11 PM

You haven't coded the hashtable correctly. Your walking script should be like this:

 iTween.MoveTo(gameObject, new Hashtable {
     { "path", iTweenPath.GetPath("myWalkingPath") },
     { "time", 5 }, 
     { "orienttopath", true } });

Also, since you're manually setting positions for the path you don't need to be dealing with the iTweenPath class. Instead you can just use a Vector3[] or better yet a List<Vector3> . This will give you full control and make sure nothing's going wrong behind the scenes out of your reach, if you get what I mean..

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 eitanwass · Aug 27, 2016 at 01:16 PM 0
Share

At first i did like what you suggested but it got super complicated really fast, plus i'm not setting the positions manually. i have a script which assigns a new position every 0.25 seconds.

I fixed it like this:

 iTween.$$anonymous$$oveTo (gameObject, iTween.Hash (
             "path", iTweenPath.GetPath ("myWalkingPath"),
             "speed", 5f,
             "easetype", "linear",
             "orienttopath", true,
             "axis", "y", 
             "onComplete", "FinishPath"));

And the recording script is:

 void UpdateActions(){
         if (canRecord) {
             if(timePassed != 0){
                 walkingPath.nodeCount = (int)(timePassed / recordingDistance) + 1;
                 walkingPath.nodes [walkingPath.nodeCount - 1] = player.transform.position;
             }
             timePassed += recordingDistance;
         }
     }

But the positions aren't being recorded unless the game obeject which records the positions is viewed in the inspector which is another bug itself. do you know how to fix that?

avatar image dhore eitanwass · Aug 27, 2016 at 01:44 PM 0
Share

Sorry, I've never used the iTweenPath class so I don't have any understanding of the functions that you're calling... nor have I used iTween.Hash ..I've always used new Hashtable and by setting the positions manually I just meant that you're setting them yourself through code rather than iTween creating them itself dynamically.

Here's an example of what I'm talking about with Lists and such:

 List<Vector3> walkingPath = new List<Vector3>();
 float lastUpdateTime = 0f;
 
 void Update()
 {
     if (lastUpdateTime + 0.25f < Time.time)
     {
         // avoid duplicates
         if (walkingPath[walkingPath.Count - 1] != player.transform.position)
             walkingPath.Add(player.transform.position);
         lastUpdateTime = Time.time;
     }
 }
 
 // call whenever you want the gameObject to start following the path
 void FollowPath()
 {
     iTween.$$anonymous$$oveTo (gameObject, new Hashtable {
             { "path", walkingPath.ToArray() },
             { "speed", 5f },
             { "easetype", "linear" },
             { "orienttopath", true } });
 }
avatar image eitanwass dhore · Aug 27, 2016 at 01:47 PM 0
Share

Hashtable seems to be the same as hash but with curly brackets "{, }". Thank you any way :)

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

72 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 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 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 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Gokit tween path position on different screen sizes 0 Answers

How to get external import filepath in AssetPostprocessor to auto import dependencies? 0 Answers

Having trouble loading unity 5.3.4p1 game with oculus cv1 0 Answers

IAP and Unity Cloud Build 1 Answer

SVGAssets 1.3.5 build for iOS error 0 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