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 wesley · Apr 11, 2011 at 08:16 AM · cameratriggeron

camera on trigger??

hey guys i have a question if i want to view camera2 when trigger gets collided with enything in the sene so it will switch to camera2 i think the script i need is somthing like this.

Function OntriggerEnter (Collission.Collider); {
Camera2 render.renderer = true;
}

does this do what i want i think so but you see i probely know what i shoud type in the script onley i dont know exactly with all the points and dots and brekkets so can you help me out thanks

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

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by GesterX · Apr 11, 2011 at 08:39 AM

Instead of having multiple cameras I would just change the position of the main camera upon entering the trigger.

Setup

  • Make sure you camera is tagged as "MainCamera".
  • Create an empty gameobject
  • Position and rotate the gameobject to the position you want your camera to appear in
  • Add a collider to the empty gameobject and scale/position it. Tick the isTrigger box.
  • Create a new javascript with the code below and attach it to the empty gameObject.

    var mainCam : GameObject;

    function Awake() { //set the mainCam variable to the MainCamera mainCam = GameObject.FindWithTag("MainCamera"); }

    function OnTriggerEnter (other : Collider) { //check that the player has entered the trigger and not an enemy/other object if (other.tag == "Player") { //set the position of the camera to the current game objects position mainCam.transform.position = transform.position; //set the rotation of the camera to that of the game object rotation mainCam.transform.rotation = transform.rotation; } }

    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 GesterX · Apr 11, 2011 at 08:43 AM 0
    Share

    The code button just is NOT working for me >_<

    avatar image
    0

    Answer by efge · Apr 11, 2011 at 01:39 PM

    The camera component can be enabled or disabled like this (without accessing the collisionInfo):

    function OntriggerEnter () {
      Camera2.enabled = true;
    }
    
    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 gochi7 · Mar 13, 2012 at 11:55 AM 0
    Share

    would this not cause an error because your not disabling the 1st camera

    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

    1 Person is following this question.

    avatar image

    Related Questions

    on trigger enter 1 Answer

    Camera movement causing UI Pointer Enter/Exit triggers to break? 0 Answers

    Moving (teleporting) player and camera when they enter a certain area 5 Answers

    How to make camera position relative to a specific target. 1 Answer

    Using switch/case with Colliders and Cameras 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