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
1
Question by McMutton · Apr 07, 2011 at 01:57 AM · camerarotatearoundorbitcircular

Getting a scrolling camera to orbit around a circular walkway, following the player?

Gentlemen!

Currently, I'm making a scene where the area the player can move around in is basically a ring (A walkway going around a circular structure). What I'm wanting to do is make the camera follow the player as they move around, but instead of it looking at them directly, I want it to always look at the center of the circular structure:

alt text

GRAY is the structure, GREEN is the walkway, PURPLE is the player, RED is the camera and its path.

Basically, the line should always be going through the player, and to the point at the center of the structure. When the player moves, the camera should follow the path of the red ring.

How should I go about doing this?

Comment
Add comment · Show 1
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 KeithK · Apr 08, 2011 at 07:07 AM 0
Share

$$anonymous$$c$$anonymous$$utton, did my solution below not help?

1 Reply

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

Answer by KeithK · Apr 07, 2011 at 06:54 AM

Give this a shot.

Create an Empty GameObject. This will be your CameraPivot point and will be positioned in the center of your circular level, so where your Camera path ends in your diagram above.

Take your Camera, and make it a child of your CameraPivot. This will ensure it inherits the transforms of CameraPivot.

You will have to make sure you have your Camera looking at the "back" of your CameraPivot. So basically as long as your Camera has a 180 rotation on it's Y-axis and is looking at the CameraPivot.

Now the magic!

In your CameraPivot script create a target variable. This target will be your player character. I'm going to write this in C#, but can change it if you're using JS and can't port it.

public Transform targetLookAt;

After assigning this script to your CameraPivot, you can drag your player instance from the Editor onto the "Target Look At" property in the Inspector. Or you can assign it however else you want really.

So now, all you need to do is keep your CameraPivot looking at your targetLookAt and your Camera will adapt :)

void Update()
{
   transform.LookAt(targetLookAt);
}

In your Camera you can just add, if you want, whatever logic you want to use to keep the Camera a certain distance from it's Parent's (the CameraPivot) targetLookAt.

Comment
Add comment · Show 3 · 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 Joshua · Apr 07, 2011 at 08:55 AM 0
Share

Clever solution.

avatar image McMutton · Apr 20, 2011 at 01:23 PM 0
Share

Ah, excellent. There's a bit of a lack in camera control, but this will do nicely.

avatar image Bren · Sep 12, 2012 at 06:28 PM 0
Share

The camera spins wildly around it's Z when the camera is at the pole.

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 Orbit Rotation Problem 0 Answers

Rotating and orbiting an game object with a stop angle 0 Answers

Keep camera horizontal with RotateAround 1 Answer

Based on touch rotate camera object 0 Answers

How Do I Simulate First-Person Without Clipping Player Model? 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