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 /
This post has been wikified, any user with enough reputation can edit it.
avatar image
0
Question by qwertyqaz · May 11, 2012 at 08:21 AM · android

ThirdPersonCamera giving Invalid Cast Error in Android

I get this error

InvalidCastException: Cannot cast from source type to destination type. ThirdPersonCamera.Awake () (at Assets/Standard Assets/Character Controllers/Sources/Scripts/ThirdPersonCamera.js:52)

my platform is android

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 syclamoth · May 11, 2012 at 08:38 AM 0
Share

Presumably, this is happening because you are trying to cast from a type that isn't able to be converted into the desired type. I'd tell you how to fix it, but I don't know the exact circumstances unless you also post the line that caused the error.

In general, make sure you are specifying the type of every variable. That can help avoid this kind of problem.

avatar image qwertyqaz · May 11, 2012 at 08:40 AM 0
Share

the error leads me to this line "var characterController : CharacterController = _target.collider;" does this help?

1 Reply

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

Answer by syclamoth · May 11, 2012 at 08:54 AM

What type is '_target.collider'? Usually that returns a Collider, not a CharacterController. Try using

 _target.GetComponent.<CharacterController>();
Comment
Add comment · Show 8 · 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 qwertyqaz · May 12, 2012 at 09:07 AM 0
Share

so do I swap that line i posted with yours. also someone down voted every one of my posts for no reson

avatar image aldonaletto · May 12, 2012 at 09:24 AM 0
Share

This comment deserved to become an answer, thus I converted it - and this question didn't deserve a down vote, thus I upvoted it! Downvotes without explanation are totally useless.

avatar image qwertyqaz · May 12, 2012 at 09:25 AM 0
Share

thankyou that fixed it. sorry cant up vote you -6 kama DX

avatar image Bunny83 · May 12, 2012 at 10:10 AM 2
Share

@qwertyqaz: I just looked through your "-1" questions and all actually deserve the downvote. You asked serveral things that has already been asked several times, that are well explained in the documentation or that is to argumentative ("can i do this or this").

This site is for specific questions about Unity that are useful to at least one other person. Usually all the "Fix my code"-questions doesn't directly meet this requirement, however if it's a good worded question and it's demonstrate a common problem it's ok. $$anonymous$$ost of your questions however are single-line questions with around 15 words.

If you need help, take the time to describe your problem. A lot people just come here for a quick personal help for free. Google doesn't $$anonymous$$d if you ask the same question 1000 times, but we aren't an automatic answering-machine for people that are simply to lazy to search first on their own.

avatar image Bunny83 · May 12, 2012 at 10:16 AM 1
Share

Btw, i just like to add that a CharacterController IS a collider, a special kind of. It is derived from collider so if a CharacterController is attached to the gameobject, the collider property will return the CharacterController. However the type returned be the property is just Collider so it need to be casted into a CharacterController. Usually UnityScript does this under the hood, but on Android you are required to use strict typing.

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

6 People are following this question.

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

Related Questions

A node in a childnode? 1 Answer

Can't use Unity Remote 4 in Unity 4.5 1 Answer

Joystick won't move in Unity 0 Answers

native android plugin 0 Answers

Converting Android Axis to Unity Axis 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