• 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 Cyanide · Jan 10, 2013 at 08:41 AM · game development

How do I make a third to first person transition

I'm working on a project where you rely heavily on summoning bots from your inventory, and using them in field, sort of like when you switch from Mason to the claw, in call of duty. My real question is, how do you switch from a third person character, to a first person item? (the item being the robot that you can control) 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
Wiki

Answer by tosi · Jan 10, 2013 at 09:44 AM

Untested, but i hope you get the idea. If you minion is destroyed, then its camera component also gets destroyed automatically. You get a call of OnDestroy() and just have to forward it to your main camera and enable it again.

Add this script to your main camera:

 #pragma strict
 
 private var minion : GameObject;
 private var minionCam : Camera;
 
 function Update() 
 {
     if( Input.GetKeyUp( KeyCode.E ) ) {
 
         if( !minion ) {
             return;
         }
         
         if( minionCam ) {
             Destroy( minionCam );
             camera.enabled = true;
         } else {
             camera.enabled = false;
             minionCam = minion.AddComponent( Camera );
         }
     }
 }
 
 
 function OnCreateMinion()
 {
     // do some code to get your minion
     // depends on your game design
 
     // minion = GameObject.FindWithTag( "minion" );
     // or 
     // it was picked before by a mouse click
 }
 
 
 function OnMinionDestroyed()
 {
     camera.enabled = true;
 }

 

And add this script to your minion:

 #pragma strict
 
 
 function OnDestroy()
 {
     Camera.main.SendMessage( "OnMinionDestroyed" );
 }
 
Comment
Add comment · Show 6 · 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 Cyanide · Jan 10, 2013 at 08:23 PM 0
Share

I understand what you're saying, but how do I go about scripting that? Say I want to press "E" to switch to the robots POV until the robot gets destroyed, and the game forces you back into the characters POV.

avatar image tosi · Jan 11, 2013 at 08:11 AM 0
Share

Updated my answer in respect of your comment.

avatar image Cyanide · Jan 11, 2013 at 11:21 PM 0
Share

Thank you very much, does this include being able to switch between cameras at all times? (until one of them is destroyed)

avatar image tosi · Jan 14, 2013 at 07:49 AM 0
Share

Pressing the button "E" is working all the time. But the code is written to switch once to the camera of your robot. If you pressed "E" again and again, nothing would happen.

avatar image Cyanide · Jan 14, 2013 at 09:20 PM 0
Share

Is there a way I can get the cameras to switch every time I press e?

Show more comments
avatar image
0

Answer by Karsnen_2 · Jan 15, 2013 at 02:38 PM

It would depend on how you are positioning the camera on the hierarchy pane.

For example, if your camera is a child to the Target Player then just try to adjust the local Space along with rotational adjustments if needed.

If you camera is not a child to the target Player then

  • A Child the camera to the Target Component at a specific point on the target component for FPS.

  • You might be doing certain Mathematical calculation behind to figure out the distance & rotation between the Target and the Camara. So, you could just lerp it to the required FPS Settings and change those values.

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

10 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

Related Questions

lightmaps vs lights 1 Answer

How can I create a free developer license to create PSVita programs with unity? 1 Answer

how to cancel my subscription about Unity Game Dev Courses at any time? 1 Answer

inheritance - problem setting class variable from external call 0 Answers

Playmaker or Game Creator (non-coder) 0 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