• 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
Question by user-1846 (google) · Apr 27, 2010 at 12:14 AM · zoomthird-personfirst-person

Zoom out from First Person to Third Person

Hello!

Would it be possible to have a camera zoom out from a first person view to a third person view (smoothly) when you hit a button?

Thanks!

Christian Stewart

Comment
Random Indie

People who like this

1 Show 0
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

3 Replies

· Add your reply
  • Sort: 
avatar image
Best Answer

Answer by Chapter9 · Apr 30, 2010 at 04:17 PM

Hi,

Here's a quick and dirty Camera Manager...

To create a first person/third person camera, create two empty object called FirstPerson and ThirdPerson and add them as a children of the main character. Position them as they would be a camera. Then add this script to your camera and set the DestinationObject default property to the FirstPerson Object. When you want to switch to the third person, change the CameraInterpolate.DestinationObject variable to the ThirdPerson object.

I recommend you to learn about Unity Interpolation functions, they are quite useful. Making a good 3d game camera is a lot more than that and quite complicated, but this will get you started...

using UnityEngine; using System.Collections;

public class CameraInterpolate : MonoBehaviour {

 public GameObject DestinationObject;
 public float Speed = 10;

 void Update () {

     if (DestinationObject)
     {
         // Interpolate from current position to the destination object position and orientation
         Vector3 newposition = Vector3.Lerp(transform.position, DestinationObject.transform.position, Time.deltaTime * Speed);
         Quaternion newrotation = Quaternion.Slerp(transform.rotation, DestinationObject.transform.rotation, Time.deltaTime * Speed);
         transform.position = newposition;
         transform.rotation = newrotation;
     }
 }

}

Comment

People who like this

0 Show 0 · 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

Answer by Random Indie · Apr 27, 2010 at 10:52 AM

Check out the 3rd Person Shooter Example.

IIRC the pertinent game objects are the player, AimTarget, MainCamera, and the Third person camera controller script (can't remember it's name exactly but it's attached to the camera).

Using the camera controller script you can set the camera inside your character's head (I think the variable was camOffset). You would then want to add another Vector3 (say thirdPerson Offset) and just slerp or lerp the camera between the two coordinates when a button is pushed.

There's another vector3 called pivot offset in there, you'll want to center that on your object then raise the camOffset above that into the character's head.

If you do it this way, you get built in camera collision (if the camera hits say a wall, it will move toward the player so that they aren't blocked by say a column or a tree) in third person.

Hope that helps!

P.S. You shouldn't be able to see your character when in 1st person mode this way as you'll be looking at the back sides of the polygons therefore they shouldn't render.

Comment
Tuti

People who like this

1 Show 0 · 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

Answer by spinaljack · Apr 27, 2010 at 09:23 AM

You can set 2 cameras, one for fps and one for 3rd person, toggle them on and off with a button. When you toggle from fps to 3rd person move the transform of the 3rd person camera to the same world position as the fps cam and then it should pull back by itself (assuming you've set a target distance for the 3rd person camera to be behind the player)

Comment

People who like this

0 Show 0 · 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

No one has followed this question yet.

Related Questions

How to make two cameras face the same direction? 1 Answer

Making a game third person and first person 1 Answer

Transition between 1st person and 3rd person cameras 2 Answers

First Person Camera switch to Third Person Camera on Object 2 Answers

How to make a button that switches from 3rd person mode to first person mode? 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