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
0
Question by maaboo · Jan 12, 2013 at 03:17 PM · erroritweeninvalidcastexception

iTween: Cannot cast from source type to destination type.

Hi!

I use the following code to test the animation before writing a bunch of code:

 Vector3 _position = new Vector3(326, -30, -1);
 GameObject _boat = (GameObject)Instantiate(boatPrefab, _position, Quaternion.identity);
 iTween.MoveTo(_boat, iTween.Hash("path", path, "speed", "10", "orienttopath", "true", "easetype", "easeInOutSine", "oncomplete", "complete"));


And got an error:

InvalidCastException: Cannot cast from source type to destination type.

iTween.GenerateMoveToPathTargets () (at Assets/iTween/Plugins/iTween.cs:3580) iTween.GenerateTargets () (at Assets/iTween/Plugins/iTween.cs:3158) iTween.TweenStart () (at Assets/iTween/Plugins/iTween.cs:4598) iTween+c__Iterator8.MoveNext () (at Assets/iTween/Plugins/iTween.cs:6555) Any help will be appreciated.
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 maaboo · Jan 14, 2013 at 05:58 PM 0
Share

Here is the sample with unwanted rotation of game object while it's moving along itween path. I see the same rotation for sprite and for cube. It rotates only "orienttopath" is set to "true".

unwanted_rotate.zip (255.4 kB)

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Nanashi91 · Jan 12, 2013 at 05:11 PM

Hello. Your MoveTo-function has some invalid arguments. Try to write it like that:

 public Transform boatPrefab;
     
     // Use this for initialization
     void Start () {
         Vector3 _position = new Vector3(326, -30, -1);
         GameObject _boat = (Instantiate(boatPrefab, _position, Quaternion.identity) as Transform).gameObject;
         iTween.MoveTo(_boat, iTween.Hash("path", iTweenPath.GetPath ("path"), "speed", 2, "orienttopath", true, "easetype", iTween.EaseType.easeInOutSine, "oncomplete", "complete"));
     }
     
     void complete(){
         Debug.Log ("complete");
     }

I dont know if your variable path is a vector or anything else. I created a path with the name path. To create the path I used the iTweenPathEditor. The project of this example: Example1

If you want to make it without iTweenPath:

 void Start () {
   Vector3 _position = new Vector3(326, -30, -1);
   Vector3[] path = new Vector3[2];
   path[0] = new Vector3(326, -30, -1);
   path[1] = new Vector3(320, -20, 0);
         
   GameObject _boat = (Instantiate(boatPrefab, _position, Quaternion.identity) as Transform).gameObject;
     
   iTween.MoveTo(_boat, iTween.Hash("path", path, "speed", 20, "orienttopath", true, "easetype", iTween.EaseType.easeInOutSine, "oncomplete", "complete"));
 }



new unity project 1.zip (254.1 kB)
Comment
Add comment · Show 6 · 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 maaboo · Jan 12, 2013 at 09:24 PM 0
Share

I made it as in samples: an array with points.

I tried your code, but: error CS0103: The name `iTweenPath' does not exist in the current context.

What is iTweenPath.GetPath? iTween has no such method and i have no iTweenPath (is it an extension to the iTween?).

avatar image maaboo · Jan 13, 2013 at 10:16 AM 0
Share

After few tries i get another error:

NullReferenceException: Object reference not set to an instance of an object.

Although, i set a link to prefab in Inspector.

avatar image Nanashi91 · Jan 14, 2013 at 08:47 AM 0
Share

oh I'm sorry. Additionally to the iTween of the Unity Store I imported the iTween Path Editor. This includes also a script called iTweenPath. I edited my answer and added the link to the iTweenPathEditor and my example project.

avatar image Nanashi91 · Jan 14, 2013 at 09:48 AM 0
Share

I can´t reproduce your Exception. Can you post some code? $$anonymous$$aybe another reference is missing.

avatar image maaboo · Jan 14, 2013 at 01:29 PM 0
Share

I made it with a iTween Path Editor (thanks for clue), but got another issue. This time with "orienttopath". It just doesn't work. If i set it to "false" — i see the sprite and animation, if "true" — see nothing. But i strongly need to set it "true".

I suspect that i need to contact with iTween developer to fix it.

Show more comments

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

9 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

What does this mean ? 1 Answer

BuildAssetBundle results in System.InvalidCastException 2 Answers

How to animate a moving platform GameObject? 2 Answers

Unknown Identifer 'iTween' 1 Answer

Strange physics, rigidbody, iTween activity 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