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 Maulik2208 · Dec 17, 2012 at 09:10 AM · cameramovedynamically

how to make camera to center the dynamically placed objects?

Hi guys......i am having number of cubes which are dynamically placed by a script and i want to show them in perfectly in center......means i can place cubes in a manner that they could be 3 by 3 or 4 by 4 or any other matrix.....so now what i want is that i have to show them perfectly in center so how could i do that??? any help will be much appreciated Thanks a lot in Advance.......if providing script then please use c#.......Thanks again.....

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
1
Best Answer

Answer by Fattie · Dec 17, 2012 at 11:40 AM

  1. to find the center point of many items:

add them all up. and then divide by the number of items.

So if you have ten items it is ( A1 + A2 + A3 ... + A10 ) / 10.0

Note that the simplest example of this is: if you need the middle point between two things, it's (A+B)/2.0.

If you have all your items in an array: use a for loop to add them all up and then divide by the count. Unless we know exactly how you handle the items, it's hard to help you with that.

  1. now you the the central position, CP, of all the items.

quite simply, use "LookAt" on your camera, with CP, to make the camera look at CP.

Hope it helps.

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 Setzer22 · Dec 26, 2012 at 03:40 PM 0
Share

Does the / operator work on the Vector3 class? I'm just curious, I always divide each component (x,y and z) individually.

avatar image Fattie · Dec 26, 2012 at 03:51 PM 0
Share

yes, that is exactly correct! it works fine.

you can say

  • 0.20;

or you can say

/ 5.0;

Be sure to click here:

Contents/Documentation/Documentation/ScriptReference/Vector3.html

notice all the functions. Look at the BOTTO$$anonymous$$ of the blue functions.

It tels you everything about the different operators!

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

11 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

Related Questions

How to make your character move? 7 Answers

How to make camera position relative to a specific target. 1 Answer

MoveTowards problem 1 Answer

Switching Cameras at runtime 1 Answer

button click to move camera to another position 2 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