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 MrSpy3456 · Apr 13, 2014 at 03:15 PM · how manysurface normal

How to identify a different camera? Urgent

Hello how do I identify a different camera in javascript other than main for e.g

Normally I would put down something like this: Camera.main but in this scenario it wouldn't be suitable I want to use a different camera other than the main one. Thanks!

Comment
Add comment · Show 5
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 Alanimator · Apr 13, 2014 at 03:21 PM 0
Share

use GameObject.FindWithTag("CameraTag");

avatar image Scribe · Apr 13, 2014 at 03:56 PM 0
Share

or if you its always the same camera you want to use, why not just define a variable that you drag it into a la:

 var otherCam : Camera;
avatar image jamesflowerdew · Apr 13, 2014 at 04:01 PM 0
Share

if it's an unusual camera not identifialble by camera.main or camera.allCameras[0] you could try whipping through the allcameras[] array with a for loop checking for the name if (camera.allcameras[number].name=="thename"){

may it also be easier to define this camera at startup or with a draggable public variable?

avatar image MrSpy3456 · Apr 13, 2014 at 04:27 PM 0
Share

Thanks ALOT!

avatar image robertbu · Apr 13, 2014 at 04:29 PM 0
Share

A Camera can be treated just like any other component in Unity. Getting a component is always a two step process (though Unity may hide the steps in some situations like dragging and dropping on a variable). Step #1: find the game object that has the component. Step #2: Use GetComponent() to get the component.

  • http://docs.unity3d.com/412/Documentation/ScriptReference/index.Accessing_Other_Components.html

  • http://docs.unity3d.com/412/Documentation/ScriptReference/index.Accessing_Other_Game_Objects.html

  • http://unitygems.com/script-interaction-tutorial-getcomponent-unityscript/

  • http://unitygems.com/script-interaction1/

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by mavasher · Apr 13, 2014 at 04:07 PM

There are lots of ways to do this:

1)Define a Tag on the necessary camera in the inspector.

in script use GameObject.FindWithTag("YourTagHere")

2) Put a unique name on the camera.

in script use GameObject.Find("YourNameHere")

3) Create a public GameObject variable at the beginning of your script then in the inspector drag the camera into that public GameObject slot.

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

25 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

Related Questions

Aligning an object with surface normal 1 Answer

Building my own benchmarking program 1 Answer

Security: Sending RPC to all clients 0 Answers

How to destroy a gameobject when I collide with it? 2 Answers

How to "push" CharacterController off of a wall's surface normal? 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