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 Esindesign · Dec 01, 2011 at 11:14 AM · cameramovementorbitselections

Moving replacing center object with orbiting object

Hey there, i'm pretty new at scripting. I'm working on a project, my scene is made up of the following. A Sphere in located in the middle of the scene, and 4 other spheres are orbiting around the center sphere. I have a camera focusing on the center object that can rotate around it and zoom in and out with smooth motion. My problem :/ is that i want to make a script that will allow me to click on one of the 4 sphere in orbit, to where the sphere that i selected will move in and replace the center sphere, and the center sphere will move out, and orbit the new center sphere.

Could anyone provide me with a script can do want i'm asking for? or just help me make one?;)

Thank you for the upcoming help ;)

Comment
Add comment · Show 2
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 syclamoth · Dec 01, 2011 at 11:25 AM 0
Share

Why did you post the camera-orbit script? It's not even relevant here! You should just post the relevant interfaces to it- what functions you have to call and what variables need to be changed to set it up. If you don't want to 'release any details', I'm afraid I won't be able to help you that much.

avatar image Esindesign · Dec 01, 2011 at 12:05 PM 0
Share

Okay, i've changed it a bit :)

1 Reply

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

Answer by ByteSheep · Dec 05, 2011 at 08:28 PM

This function could probably be a good start for what you're looking to do:

http://unity3d.com/support/documentation/ScriptReference/MonoBehaviour.OnMouseDown.html

You could use it to detect whether you clicked on a sphere - something like:

 var target : Transform;
 var MoveSpeed : float = 2;
 
 function OnMouseDown () {
    transform.LookAt(target);
    transform.position += transform.forward * MoveSpeed * Time.deltaTime;
 }


This script would then need to be added to each sphere! This is just a quick idea, there is for example a problem = since the transform.position part is not in the Update function, the sphere won't move forwards properly.. It should be simple enough to move the transform.position etc part to the Update, but tell me if you need help with that.. The "transform.LookAt(target);" part is to make sure the sphere is looking at the center sphere and could perhaps also be placed into the Update function! Also, you will have to assign the center sphere to the "target" variable in the Inspector window. Good luck!

Comment
Add comment · Show 4 · 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 Esindesign · Dec 06, 2011 at 12:45 PM 0
Share

Hey thank you for the answer, that is what i'm trying to do, but my scripting knowledge is very limit, I would treasure any help I could get ;) So if you can maybe explain how to setup/make a script for that, it would be awesome ;)

avatar image Esindesign · Dec 06, 2011 at 01:22 PM 0
Share

Hey thank you for the answer, that is what i'm trying to do, but my scripting knowledge is very limit, I would treasure any help I could get ;) So if you can maybe explain how to setup/make a script for that, it would be awesome ;)

avatar image ByteSheep · Dec 06, 2011 at 04:22 PM 0
Share

This is a good page to look at, showing how to create and add a script to a game object:
http://unity3d.com/support/documentation/$$anonymous$$anual/Scripting.html
Once you have created the script and added it to the game object (in this case needs to be added to all spheres), you can paste the code I have given you as a starting point into the script and save it. Once you have done this you will have to make some changes to the code I have given you (explained in other answer)..
If you are still having troubles with the basics, there are lots of helpful pages you can look at. Please let me know if you have already managed to add the script to the game objects and I will try and help you with the necessary code you would need.

avatar image ByteSheep · Dec 06, 2011 at 04:25 PM 0
Share

Oh and the scripting language I have used is JavaScript so you will need to create a JavaScript file (not Boo or C sharp)

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Mouse Orbit + Move Object + Follow Problem 1 Answer

Camera Movement issue 1 Answer

Orbit around an object 0 Answers

3rd person camera/movement 2 Answers

First person camera restriction. 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