• 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 dragonfire14 · Dec 20, 2015 at 03:34 AM · c#cameracamera-movementzoomcamera movement

Problems making a smash bros like camera

I am trying to make a camera that acts like the camera in super smash bros.

It will keep all players on screen by moving horizontally and vertically, and by zooming in and out.

(edited for brevity. click the history button if you need to see it for some reason)

Any help would be appreciated. Thank you in advance.

Comment
Add comment · Show 4
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 LazyElephant · Dec 20, 2015 at 08:08 AM 0
Share

I don't have time to test it, so I'm not sure if it's the only problem, but you shouldn't be using else ifin your zoom function. In the event that the first object tested is the highest x or y, it won't register because it was already counted as the lowest.

avatar image Zoelovezle · Dec 20, 2015 at 08:26 AM 0
Share

You dont need else if there ..

avatar image Afrodeity · Dec 20, 2015 at 04:21 PM 0
Share

The else if statements should definitely stay. After all, if the player position is already smaller than the $$anonymous$$imum, there's no need to compare it to the maximum as well.

avatar image Fattie · Dec 20, 2015 at 05:15 PM 0
Share

the "else if" usage is utterly meaningless, if even needed it would be "else" in that situation. however that's quite irrelevant as the script is just generally not really right, at all. this script is so bad it's best just to be deleted for the sake of the future readers. $$anonymous$$unchy has given a great answer below

2 Replies

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by Munchy2007 · Dec 20, 2015 at 04:49 PM

The Tanks tutorial has exactly this type of camera, you should be able to adapt it to your needs quite easily.

http://unity3d.com/learn/tutorials/projects/tanks-tutorial

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
1

Answer by Zoelovezle · Dec 20, 2015 at 11:22 AM

My suggestion : You need to do tutorials provided by unity http://unity3d.com/learn/tutorials

 public bool canFocus = true ;
 //You could play with the zoomValue in inspector in play mode
 [Range(1f , 100f)]
 public float zoomValue ;
 
 private Camera _camera ;
 
 void Start()
 {
     if (!_camera)
         _camera = Camera.main ;
 }
 
 void Update()
 {
     if (canFocus)
     {
         //call the function from below as per your camera ;
     }
 }
 
 //Orthographic projection is used for 2D games
 void FocusInOrthographicView()
 {
     //See your Main Camera setting If the projection is set to Orthographic use this
     _camera.orthographicSize = zoomValue ;
      
 }
 
 //Perspective projection is used for 3D games
 
 void FocusInPerspectiveView()
 {
     //Is the projection is set to Perspective use this
     _camera.fieldofView = zoomValue ;
 }




Comment
Add comment · Show 5 · 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 Fattie · Dec 20, 2015 at 05:17 PM 0
Share

all these comments are correct but you could have stopped at "read the Unity tutorials" ;)

I just sent you five "reward points" for making such a big effort! $$anonymous$$erry Christmas

avatar image Zoelovezle Fattie · Dec 20, 2015 at 05:25 PM 0
Share

He had uploaded a script , i just wanted to correct it and give some hint over camera .....

avatar image Fattie Zoelovezle · Dec 20, 2015 at 05:33 PM 0
Share

yes, it was very heroic of you! well done.

Show more comments

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

7 People are following this question.

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

Related Questions

How to make camera zooming with a range? [C#] 0 Answers

Making camera follow upwards 3 Answers

Pinch zoom 0 Answers

Enable the OrbitCam script how can I make it will continue from the current camera view and position ? 0 Answers

Issue with my camera controls 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