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 moises2657 · Mar 21, 2014 at 09:39 PM · gameobjecterror messageside-scrollingbce0020

Assets/Standard Assets (Mobile)/Scripts/SidescrollControl.js(33,18): BCE0020: An instance of type 'UnityEngine.Transform' is required to access non static member 'Find'.

**I have a problem saving my script this is the part of the error might help me?

error: "Assets/Standard Assets (Mobile)/Scripts/SidescrollControl.js(33,18): BCE0020: An instance of type 'UnityEngine.Transform' is required to access non static member 'Find'."

code:

 @script RequireComponent( CharacterController )
 
 // This script must be attached to a GameObject that has a CharacterController
 var moveTouchPad : Joystick;
 var jumpTouchPad : Joystick;
 
 var forwardSpeed : float = 4;
 var backwardSpeed : float = 4;
 var jumpSpeed : float = 16;
 var inAirMultiplier : float = 0.25;                    // Limiter for ground speed while jumping
 
 private var thisTransform : Transform;
 private var character : CharacterController;
 private var velocity : Vector3;                        // Used for continuing momentum while in air
 private var canJump = true;
 
 
 
 private var player:GameObject;
 function Start()
 {
 
 **player=Transform.Find("player").GameObject;**
 
     // Cache component lookup at startup instead of doing this every frame        
     thisTransform = GetComponent( Transform );
     character = GetComponent( CharacterController );
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 robertbu · Mar 21, 2014 at 11:41 PM 0
Share

I'm not sure of the right solution. It depends on whether you are looking for any game object or an immediate child object, or any child object. You are getting this specific error because you are using the class rather than the instance. That is this line:

 player = Transform.Find("player").GameObject;

should be:

 player=transform.Find("player").GameObject;

Note the lower case 't'.

avatar image VioKyma · Mar 23, 2014 at 02:32 AM 0
Share

As @robertbu said, it depends on what it is you want to find. Can you give us some info about the gameObject you want to find, and the gameObject this script will be on? That way we can tell you with confidence which line you should be using. It will either be the above, or the line mentioned in my answer.

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by hellguzz · Mar 21, 2014 at 11:22 PM

Try

 player=GameObject.Find("player");
Comment
Add comment · Show 2 · 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 VioKyma · Mar 21, 2014 at 11:37 PM 0
Share

Why the GameObject at the end? GameObject.Find() returns a GameObject anyway.

avatar image hellguzz · Mar 22, 2014 at 11:04 AM 0
Share

Of course you are right.

avatar image
0

Answer by VioKyma · Mar 21, 2014 at 09:57 PM

If you are looking for a child object, then this will work, otherwise it will not.

If the script is on a completely seperate game object to the player, you could use:

 player = GameObject.Find("player");

If it is directly on the player gameObject, you don't need that statement at all as a simple gameObject will do that.

Comment
Add comment · 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

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

22 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

Related Questions

Unity Crashes when C# script with code inside class but outside function is added to a GameObject 1 Answer

How to destroy object forever? when i go to another scene and back to first, i want to that object stay destroyed! , Please !!!!  1 Answer

Acessing scripts in other game objects with prefabs, without using GameObject.Find 1 Answer

one shot Sound on collision. Unity 4.0 problem. 2 Answers

what do i write here 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