Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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 BrewsterBrock · Jul 13, 2020 at 12:55 PM · gameobjecttransformmain camera

GameObject not working with variable in C# script

I'm very new to Unity, but I've been following a tutorial on YouTube (by Brackeys) to make my first game. In the tutorial, he did 'public Transform player;', which should work as I have seen lots of people do it before. Basically my issue is linking a GameObject to a variable. The Transform component in the main camera doesn't show up in the script but I don't know why. Is anyone able to help solve this..?

Sorry if my terminology isn't right, I'm still very new.

Here is a link to the video: https://www.youtube.com/watch?v=HVB6UVcb3f8 I did exactly what he did, and for the main camera, but Transform isn't showing up for the public variable. (Around 1:35 in the video.)

 public class FollowPlayer : MonoBehaviour
 {
     public Transform player; // This is the part that doesn't work - when I continue it normally changes it to CryptoAPITransform because Transform isn't available.
     // Start is called before the first frame update
     void Start()
     {
         
     }
 
     // Update is called once per frame
     void Update()
     {
         
     }
 }

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 gjf · Jul 13, 2020 at 01:34 PM 1
Share

Try posting your code (make sure that you tag it correctly - see the FAQ) and include a link to the tutorial, in case your errors are not obvious.

avatar image BrewsterBrock gjf · Jul 14, 2020 at 05:58 AM 0
Share

I've updated the post.

3 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by AaronSxng · Sep 02, 2020 at 08:02 PM

Hey this worked for me. https://www.youtube.com/watch?v=5LX13Xqc50g

Go to Edit -> Preferences -> External Tools -> External Script Editor, and change it to Visual Studios.

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

Answer by haizathaneefa · Jul 14, 2020 at 06:04 AM

Have you tried changing it to something else other than transform? GameObject for example.

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 BrewsterBrock · Jul 14, 2020 at 06:11 AM 0
Share

I've just tried that, and it doesn't seem to work either. I don't know what I'm doing wrong.

avatar image xxmariofer BrewsterBrock · Jul 14, 2020 at 06:17 AM 0
Share

it is imposible the transform gets changed to CryptoAPITransform i bet you already have 2 classes with similar names or something like that, simply crea$$anonymous$$ new cs script and add that line and test it again

avatar image haizathaneefa BrewsterBrock · Jul 14, 2020 at 06:19 AM 0
Share

try to make a new project and a new scene and try that video out. If it works then something inside of your previous project is causing the error.

avatar image
0

Answer by BrewsterBrock · Aug 19, 2020 at 12:57 AM

Update: I tried fixing this by restarting the project a bunch of times, but it still didn't work. In the end, I switched to Brackets instead of Visual Studio and it worked just fine. Hopefully this helps someone.

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

228 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 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 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 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

How to move a Game Object from a script not attached to it. 1 Answer

Cannot place checkpoints position into Transform array 1 Answer

Destroy Gameobject on Collision not working? 3 Answers

problems parenting a gameObject to another upon instantiating when same name exists 1 Answer

Keep adding targets to a list 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