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 /
  • Help Room /
avatar image
0
Question by Mumbo-Jumbo-15 · Oct 21, 2016 at 09:35 PM · 3rd person controller3rd person camera3d platformer tutorial

Need help with a 3rd person Camera

I'm trying to recreate TP_Camera from https://www.3dbuzz.com/training/view/3rd-person-character-system/simple-character-system/14-tpcamera-sec-func-implementation

This is the script as written in the Tutorial.


  public static void UseExisitingOrCreateNewMainCamera()
 {
     GameObject tempCamera;
     GameObject targetLookAt;
     TP_Camera myCamera;

     if (Camera.main != null)
     {
         tempCamera = Camera.mainCamera.gameObject;
     }
     else
     {
         tempCamera = new GameObject("MainCamera");
         tempCamera.AddComponent("Camera");
         tempCamera.tag = "MainCamera";
     }

     tempCamera.AddComponent("TP_Camera");
     myCamera = tempCamera.GetComponent("TP_Camera") as TP_Camera;

     targetLookAt = GameObject.Find("targetLookAt") as GameObject;

     if (targetLookAt == null)
     {
         targetLookAt = new GameObject("targetLookAt");
         targetLookAt.transform.position = Vector3.zero;
     }

     myCamera.TargetLookAt = targetLookAt.transform;
 }

This is the script after automatically converting it to the new API.


  public static void UseExisitingOrCreateNewMainCamera()
 {
     GameObject tempCamera;
     GameObject targetLookAt;
     TP_Camera myCamera;

     if (Camera.main != null)
     {
         tempCamera = Camera.main.gameObject;
     }
     else
     {
         tempCamera = new GameObject("MainCamera");
         tempCamera.AddComponent<Camera>();
         tempCamera.tag = "MainCamera";
     }

     tempCamera.AddComponent<TP_Camera>();
     myCamera = tempCamera.GetComponent("TP_Camera") as TP_Camera;

     targetLookAt = GameObject.Find("targetLookAt") as GameObject;

     if (targetLookAt == null)
     {
         targetLookAt = new GameObject("targetLookAt");
         targetLookAt.transform.position = Vector3.zero;
     }

     myCamera.TargetLookAt = targetLookAt.transform;
 }
 

This method no longer works. It does not find a camera to tag as "MainCamera", nor does it create a camera to tag. It neither finds, nor creates, targetLookAt When I start the scene with a gameobject called targetLookAt it does not find the gameobject and is unable to be instanced by dragging it to the TP_Camera in the inspector without it crashing.

UseExisitingOrCreateNewMainCamera() is also called in TP_Controller and is vital to the controller working. As is, the scene fails to initiate after clicking play. It just sits and tries to start indefinitely.

The scene will only play if I comment out UseExisitingOrCreateNewMainCamera() in TP_Camera and removing it from the awake method of TP_Controller.

Well, what I really want to be able to do is to attach my TP_Camera script to a gameobject and start the scene without a camera in it. The script should look for a camera, not find one, then create a camera named and tagged "MainCamera". I also want it to do the same thing with the object "targetLookAt". As is, when I attach TP_Camera to a capsule with a character controller and hit play in a scene with no camera it just plays the scene without a camera in it. The Game tab just says "Display 1 No Camera Rendering". I'm using the latest version of unity. Sorry if I don't quite understand, I'm new.

Here are the scripts that I am using, applied to a capsule with a character controller:

https://drive.google.com/drive/folders/0Bzywz7Vlm7NlRktndl90NG5FLUU?usp=sharing

Thank you for your time.

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

0 Replies

· Add your reply
  • Sort: 

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

76 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

Related Questions

Need help with my 3RD person Script being buggy!! 0 Answers

3rd Person Camera Controller, Character should follow the Camera Movement 0 Answers

Scripting Problem Please Help Me to adjust this Script 0 Answers

3rd person controller acting odd after hitting collider 0 Answers

How to make a space ship fly after crosshair? 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