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
2
Question by Jesus_Freak · Jun 30, 2011 at 02:38 AM · errormoveitweenpathitweenpath

How to animate a moving platform GameObject?

My updated script:

 using UnityEngine; 
 using System.Collections; 
 using System.Collections.Generic;
 
 public class CountChildren: MonoBehaviour {
     
     public List<Transform> children = new List<Transform>();
     public bool animate;
     public bool sendMat;
     public Material[] mat;
     
     int time = 5;
     
     void Awake() {
         
         
         foreach(Transform child in transform) {
             children.Clear();
             children.Add(child);
         }
         print(transform.childCount);
         for(int i=0; i<children.Count; i++) {
             children[i].renderer.sharedMaterial = mat[0];
             if(sendMat) BlockLift.ReColor(mat[1]);
         }
     }
     
     void Update() {
         if(animate) {
             iTween.MoveTo(gameObject, iTween.Hash("path",iTweenPath.GetPath("pathPlatform"), "time", time));
             Debug.LogError("iTweenPath made a path, but this gameObject is not moving along it!");
         }
     }
 }

At runtime, my LogError shows up in the console, and my platform is not moving along the path!

that error is just a form of Debug(), not a real error. and there's no real error showing up... so what's wrong?

Comment
Add comment · Show 7
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 fireDude67 · Jun 30, 2011 at 04:49 AM 0
Share

Gah my comment got turned into an Answer...anyways what I was saying was "what do you mean??"

avatar image Jesus_Freak · Jun 30, 2011 at 05:03 AM 0
Share

how do you put the gameObject on an iTween created path and move it "forward" along that path?

avatar image Jesus_Freak · Jun 30, 2011 at 07:25 AM 0
Share

Any and all comments/answers/solutions Wanted! If you know ANYTHING about the errors or why it crashes Unity, please help me!

avatar image fireDude67 · Jun 30, 2011 at 04:26 PM 0
Share

I was going to post an answer, so I had written it and was ready to hit, "post response" but then I forgot to press that button, and Hibernated my computer. So I had to come back in the morning and hit the button.

avatar image Jesus_Freak · Jun 30, 2011 at 09:49 PM 0
Share

Wait a second, does iTween use javascript Hash(es) to make commands? so should i make this script UnityScript?

Show more comments

2 Replies

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

Answer by fireDude67 · Jun 30, 2011 at 04:24 PM

There's an iTween tutorial on this: http://pixelplacement.com/2010/12/03/visual-editor-for-itween-motion-paths/

That helped for me. Basically you need to assign the Path to the GameObject. I watched the video a long time ago, so correct me if I was wrong.

Edit: First, iTween.MoveTo needs to be put in Start. Or, if you're doing it differently (need to launch the path later) then you need to set the animate variable to false afterwards. Also, I don't see where animate is getting set. It must be defaulting to true. But, the reason I think now that it is not moving, is because the animate variable does not get set back to false. Because of that, iTween keeps moving your object back to the start of your path. The way to correct this

 void Update() {
   if (animate) {
     iTween.MoveTo(gameObject, iTween.Hash("path",iTweenPath.GetPath("pathPlatform"), "time", time));
     animate = false;
     Debug.Log("animate is:" + animate.ToString());
   }
 }

What that does is use iTween.MoveTo() as normal, then it sets animate to false, then it prints the value of animate. When you run this script, it should output "animate is False" in the Console.

Comment
Add comment · Show 12 · 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 Jesus_Freak · Jun 30, 2011 at 08:20 PM 0
Share

I voted you up because that video was exactly what i need! now with that, I know how to make a moving path. But i had to watch this game on my PC since mac doesn't have flash-player or whatever the plugin he used to make that video, so i'll test it on my mac, and then vote you correct when it works.

avatar image Jesus_Freak · Jun 30, 2011 at 08:32 PM 0
Share

I changed my script in my answer, but i still get the same errors!

avatar image Jesus_Freak · Jul 01, 2011 at 12:56 AM 0
Share

It still gives me the errors! Do you have any idea why?

avatar image fireDude67 · Jul 01, 2011 at 03:36 AM 0
Share

Same errors? Are you SURE Path 1 exists? Are you sure it's Path 1 and not Path1? And, have you downloaded the latest version of iTween? Sometimes that does it.

avatar image Jesus_Freak · Jul 01, 2011 at 04:13 AM 0
Share

Yes, I'm sure i have the current iTween package, and i copy/pasted the name of the path from the visual path editor to this script.

Show more comments
avatar image
0

Answer by Jesus_Freak · Jun 30, 2011 at 09:45 AM

It's because my script has the field:

 [ExecuteInEditMode] 

and the script "iTweenPath" doesn't. Therefore, while my script is trying to find the path, the iTweenPath script isn't creating the path, at least not for use in any other script yet(until runtime)

but for some reason my platform isn't moving along the path!

Comment
Add comment · Show 4 · 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 fireDude67 · Jul 01, 2011 at 03:49 AM 0
Share

I removed the "Is it that" part of your answer and changed it because that makes it sound sooo much like a comment.

avatar image Jesus_Freak · Jul 01, 2011 at 04:12 AM 0
Share

oh thanks. but the answer's wrong any way. an int has NOTHING to do with it....

avatar image fireDude67 · Jul 01, 2011 at 06:08 PM 0
Share

Why'd you mark this as accepted Answer? It doesn't answer your question...does it?

avatar image P-Money · Aug 03, 2012 at 05:22 AM 0
Share

Look it up on YouTube, do a search for iTween and you'll find an example.

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

changing itween moveTo speed param. 0 Answers

Making a forked path with iTween 1 Answer

3D Text to follow a path; iTween 0 Answers

draw a path in game with touch and move player on it 0 Answers

Scale an iTweenPath 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