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 5seaton4 · May 01, 2011 at 06:18 AM · camerazoomminimap

minimap zooming c#

hello i have made a mini map and i want to be able to when i hover over the minimap it start scrolling ive made the camera scroll the problem is it scrolls my main camera as well how would i go about doing this here is the code for the scrolling so far in c#:

using UnityEngine;

using System.Collections;

public class miniMapCamera : MonoBehaviour {

public float minZoom = 2f;

public float maxZoom = 50f;

void Update() {

 camera.fieldOfView = 21f;

 if(Input.GetAxis("Mouse ScrollWheel") > 0) {

     camera.fieldOfView--;

     if(camera.fieldOfView < minZoom){

         camera.fieldOfView = minZoom;

     }

 else if(Input.GetAxis("Mouse ScrollWheel") < 0) {

         camera.fieldOfView++;

         if(camera.fieldOfView > maxZoom) {

             camera.fieldOfView = maxZoom;

         }

     }

 }       

}

}

any help will be appreciated

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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by yeoldesnake 1 · Sep 26, 2011 at 02:00 PM

You seem to be editing the main camera's field of view , if this script is attached to the object containing the main camera it will modify it's FoV as well. You can try defining the minimap camera as either a gameobject from which you will get the camera component , or directly as a Behaviour , and modify the field of view of that camera. Or you can simply remove this script from your main camera object , if the script is already attached to the minimap camera object. Another thing i saw is that you are constantly setting the camera field of view every frame in Update()

camera.fieldOfView = 21f;

I wonder how it is functional in the first place.

Another piece of advice regarding zooming in and out. It is best to use

 if(Input.GetAxis("Mouse ScrollWheel") > 0&&camera.fieldOfView > maxZoom){
             camera.fieldOfView++;
             if(camera.fieldOfView > maxZoom) {

     camera.fieldOfView = maxZoom;

       }
     }

To avoid the camera zooming in then instantly out when the FoV is equal to the minimum or maximum values , the extra check after incrementing the field of view is for precaution safety measures.

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

1 Person is following this question.

avatar image

Related Questions

Camera only panning on 1 axis 1 Answer

Zoom in on object and make other objects disappear on zoom?,Zoom in on object and make other objects disappear 0 Answers

Camera following dice with FREE UNITY DICE PACK. help 1 Answer

How to use vuforia AR Camera for Zoom 1 Answer

Drawing a minimap - need an advice 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