Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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 /
This post has been wikified, any user with enough reputation can edit it.
avatar image
1
Question by rooted · Nov 17, 2013 at 10:46 PM · cameratransformfieldofview

Smoothly move camera Field of View upon Trigger

I'd like to smoothly adjust the camera position between the original position and field of view to a new one upon a trigger and back again when exiting the trigger area.

How would I approach this, i'm a newb at this? Could someone construct a sample script for me to learn?

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 Seth-McCumber · Nov 17, 2013 at 10:53 PM 0
Share

Check out iTween, and use $$anonymous$$oveAdd from iTween

avatar image rooted · Nov 18, 2013 at 09:17 AM 0
Share

I've looked into it and have it installed. I feel it's too complicated for me at the moment but do see its value. I will have to spend some time learning how to incorporate this. Unless you could give me an example on how to use it with the code I posted below on neoncraze's comment.

avatar image Seth-McCumber · Nov 18, 2013 at 08:12 PM 0
Share

Example code

 void OnTriggerEnter(Collider Collider) {
       iTween.$$anonymous$$oveAdd(GameObject.Find("Game Object Name"), new Vector3(0, 0, 0), 1);
 }

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by neoncraze · Nov 18, 2013 at 08:16 AM

I have actually tried to do this for a project of mine and I'd suggest you look at using some of the Vector3 functions, Vector3.SmoothDamp and Vector3.Lerp, to damp/lerp your camera between positions. It works for me and should work fine for what you plan to accomplish, too. It'll be easily transferable too as you'd be able to just have variables to store the Vector3 positions of where ever you want to move your camera to.

Comment
Add comment · Show 2 · 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 rooted · Nov 18, 2013 at 08:57 AM 0
Share

I tried this but it doesn't do anything. I think it's something stupid I'm missing. It's a gameObject not attached to anything at the moment:

 #pragma strict
 var zoomOut: int = 95;
 var normal : int = 60;
 var smooth : float = 5;
 
 private var poisoned = false;
 
 function update () {
     if (poisoned == true){
         Camera.main.fieldOfView = $$anonymous$$athf.Lerp(Camera.main.fieldOfView,zoomOut,Time.deltaTime*smooth);
         }
     else{
         Camera.main.fieldOfView = $$anonymous$$athf.Lerp(Camera.main.fieldOfView,normal,Time.deltaTime*smooth);
         }
 }    
                 
 function OnTriggerEnter(other : Collider) {
     
     if (other.gameObject.name.StartsWith("Player")) { //Check that we are dealing with the player.
         poisoned = true;    
     }
 }
 function OnTriggerExit (other : Collider) {
      poisoned = false;    
     
 }
avatar image UniqueMindsGroup · Oct 10, 2014 at 11:57 PM 0
Share

Your "update" function needs to have the first letter CAPITALIZED

[SOLVED]

avatar image
0

Answer by UniqueMindsGroup · Oct 11, 2014 at 04:01 AM

Your "update" function needs to have the first letter CAPITALIZED [SOLVED]

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

20 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

how to change orbit camera rotation when player runs into trigger box 1 Answer

Offsetting local positions 2 Answers

How do i lock the position of the camera above the player relative to the origin point? 0 Answers

Camera movement in a 2D? (like angry birds) 1 Answer

Change position of camera on scene load? 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