Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 Davinder_Singh · Jun 11, 2017 at 12:00 AM · c#camera3daccelerationfield of view

Smooth transition between Camera FOV and GameObject

Hello friends,,, I am a beginner in unity, I am making a 3d game in which I want the field of view of camera increase smoothly with the increase in speed of my moving game object (currently a cube) & vice versa. I am using transform.translate to move my cube for now, but it doesn't seem to work for me till now to even accelerate and to change FOV either. But I would say that I have tried Mathf and Vector.Lerp too for doing what I want but I didn't get the results. Any help would be appreciated. Thanks in advance.

Comment
Add comment · Show 1
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 hexagonius · Jun 11, 2017 at 09:16 AM 0
Share

Lerp, translate and all are pretty straight forward. "Trying" doesn't sound like well thought out. Think the whole problem through, then code it. Lerp is definitely possible, it just depends on how you implement it.

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by Davinder_Singh · Jun 13, 2017 at 04:11 AM

@JeffHardddyyy I think, I didn't asked question properly... But still, looking at your this script, I have got idea for my game's script and the problem is half solved. Now the only problem remaining is of how to accelerate and de-accelerate my game object. Problem of FOV is solved. ;)

Thanks for that.

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 JeffHardddyyy · Jun 27, 2017 at 11:23 PM 0
Share

No Problem!

avatar image
0

Answer by JeffHardddyyy · Jun 11, 2017 at 11:45 PM

Hopefully this works! Sorry you had to wait 24 hours to answer, Lol!

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 
 public class myScript : MonoBehaviour
 {
 
 
     public Camera myCam; //the camera
     public int amount; //how many times do you want it to
 
     void Start()
     {
         for (int i = 0; i < amount; i++)
         {
             myCam.fieldOfView++;
         }
     }
 }
 
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 JeffHardddyyy · Jun 11, 2017 at 11:47 PM 0
Share

Or: using System.Collections; using System.Collections.Generic; using UnityEngine;

 public class myScript : $$anonymous$$onoBehaviour
 {
 
 
     public Camera myCam; //the camera
     public float Seconds;       //how many seconds until it zooms out?
     public int How$$anonymous$$uch;         //how much should it ZoomOut
 
     void Start()
     {//on start
         StartCoroutine("ZoomCamera");       //start "ZoomCamera"
     }
 
     IEnumerator ZoomCamera()
     {//when called
         yield return new WaitForSeconds(Seconds);       //wait [Seconds] Seconds
         myCam.fieldOfView += How$$anonymous$$uch;           //add [How$$anonymous$$uch] to the field of view
 
         StartCoroutine("ZoomCamera");//loop
     }
 }
 

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

8 People are following this question.

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

Related Questions

Dark Souls like camera going through walls, please help 0 Answers

Limiting vertical camera rotation 0 Answers

Why is the camera going crazy when the player moves? 0 Answers

Multiple Cars not working 1 Answer

Change from 3D to 2D 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