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 RickTick · Aug 18, 2012 at 07:02 PM · camerapathfollow player

camera following player on path

Hi,

is there a good workaround for a camera which is following the player on a predefined path (not behind, but on the side of the player)?

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

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by ScroodgeM · Aug 18, 2012 at 07:24 PM

you can set camera's position as you wish:

always behind player

Camera.main.transform.position = playerTransform.position - playerTransform.forward * 3f;

always to right of player

Camera.main.transform.position = playerTransform.position + playerTransform.right* 3f;

always to right in world space (camera will not rotate on player's rotate)

Camera.main.transform.position = playerTransform.position + Vector3.right* 3f;

always to right and a little at top of player

Camera.main.transform.position = playerTransform.position + playerTransform.right* 3f + playerTransform.up;

also, don't forget to set 'look at' for camera to turn it to player

applying setting position in Update will move camera always following the player

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 RickTick · Aug 18, 2012 at 08:51 PM 0
Share

Thank you. In most this will work, but at some points the cam has to rise a little bit higher or woer, This is why I asked for paths. But I will implement you solution for now. Can you tell me what "3f" means in your code?

avatar image ScroodgeM · Aug 18, 2012 at 09:02 PM 0
Share

you can use triggers to mark some areas where camera should move somehow else.

3f is 3 in float format, same as 3.0f. 'f' needed in C# cause else 3.0 will be interpreted as double.

avatar image
0

Answer by Dragonlance · Aug 18, 2012 at 09:02 PM

Well you could implement a bezier curve or an array of them.

For this you could also use http://docs.unity3d.com/Documentation/ScriptReference/AnimationCurve.html in your code.

This is a somewhat complex matter, I think this tip is a good starting point for your research.

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

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

3d platforming Camera 1 Answer

Make the camera follow the players 1 Answer

Camera shake during follow a player with lerp and lookAt? 0 Answers

Camera target 1 Answer

User move camera along path 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