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
0
Question by pdbarro67 · May 20, 2018 at 06:04 PM · cameratutorialroll a ball

Roll-a-ball tutorial does not work.

I have gone through this tutorial from start to finish, following the instructions exactly. Though the ball moves around, the camera will not follow it, and the camera coordinates in the inspector do not seem to respond to the CameraController script at all.

I am using Unity version 2018.1.0f2

alt text



This is the CameraController script I am using (edited in VS 2010):

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 
 public class CameraController : MonoBehaviour
 {
 
     public GameObject player;
 
     private Vector3 offset;
 
     // Use this for initialization
     void Start()
     {
         //player = GameObject.Find("Player");
         offset = transform.position - player.transform.position;
     }
 
     // Update is called once per frame
     void LateUpdate()
     {
         //player = GameObject.Find("Player");
         transform.position = player.transform.position + offset;
     }
 }



I have tried some suggested fixes, including the inclusion of the player = GameObject.Find("Player");

but nothing works. I would be very grateful if somebody explain how to make this work, as I have tried every suggestion or alternative code snippet I could find in these forums and elsewhere.

The instructions must either be incomplete, or incompatible with the latest version. It would be nice if Unity could look at this.

Thanks.

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 raybarrera · May 20, 2018 at 07:40 PM 0
Share

Nothing is really jumping out at me at first glance. Can you post the player controller script as well?

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by BrilliantOne · May 20, 2018 at 09:32 PM

@pdbarro67 The issue that you are having is that you did not add the Player GameObject to the CameraController script. To do that, go to the Unity editor and select the "Main Camera" object. In the Inspector, look for the Camera Controller Script. If you look at the Camera Controller script, under Player, you will see that there is no object referenced in the Player game object slot. All you have to do now is left-click and drag the Player GameObject from the Hierarchy, and drop it on the Player slot in the Camera Controller script. Hope this solves your issue.

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 pdbarro67 · May 20, 2018 at 10:49 PM 0
Share



Hi @BrilliantOne,

Thanks very much for the suggestion. I have tried it, however it will not let me drop "Player" from Hierarchy into the Player slot. I get the little "No Entry" cursor saying it can't be dropped there.

I tried the alternate way of using the little dialog accessible from the little button to the right of the Inspector Player field, but get a null list (see picture).

alt text

I also tried adding a "Player" Tag to Player in the Inspector. No luck.

Any ideas?

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

143 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

Related Questions

How do I stop my camera rotating with my player? 0 Answers

Roll a Ball Tutorial problem 1 Answer

Unity MMO Controller Example - How to Reposition Camera? 0 Answers

Roll-A-Ball Tutorial: Ball moves on its own 3 Answers

about camera in 2D 3 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