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 megat · Mar 15, 2012 at 08:27 AM · cameracollidertriggermenuchange

Changing the camera when clicked on a collider

How do I change the position of my camera when i click on a collider. This is for a 3D menu. Do I use a trigger?

Comment
Add comment · Show 3
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 syclamoth · Mar 15, 2012 at 08:35 AM 0
Share

What have you got working already? I would use a normal collider, and raycasts. $$anonymous$$oving the camera is easy- but you need to know where to move it to.

avatar image megat · Mar 15, 2012 at 08:44 AM 0
Share

Only this var cam1:GameObject; //Assign Camera 1 var cam2:GameObject; //Assign Camera 2 var cam3:GameObject; //Assign Camera 3 var cam4:GameObject; //Assign Camera 4

Then i dont know what to do. Since i am really new to scripting

avatar image hijinxbassist · Mar 24, 2012 at 06:16 AM 0
Share

Some basics..

Do you really need all these cameras? This makes it a bit trickier, as you need to either remove unwanted audio listeners or turn them off and on constantly on corresponding cameras(you can only have one audio listener active at a time).

First things first, your camera(s) should be type Camera, not GameObject.

 var cam1:Camera;

There is the main camera(default camera when making a new scene), which you can refer to in code by using

 Camera.main;

The position of your camera will be handled by Vectors. Ex. Vector3 for x,y, and z positions.

 var cameraPosition1:Vector3;

Like syclamoth said, you can do a raycast(Physics.Raycast) to see if you're clicking on something. Theres a bit more work to do though...

Check out the http://unity3d.com/support/documentation/ScriptReference/index.html>Unity Script Reference, as this will give you examples of how the code is used. Hope this helps get you started.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by megat · Mar 16, 2012 at 12:54 AM

Alright thanks! :D

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

6 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Can't click gameobject when over another trigger? 1 Answer

How to disable gameObjects when they enter a trigger 2 Answers

Camera does not trigger OnTriggerEnter-event 1 Answer

Player triggered cutscene with collider? 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