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 Aralax · Nov 13, 2012 at 11:54 PM · camerarotationmini-map

Creating a simple mini-map?

I'm trying to create a simple mini-map for my latest project, but can't seem to get it to work entirely.

I've already created the camera, and all settings are right (depth, layer etc), so it already looks like a mini-map. The camera will follow the player on the x and z axes (not the y), but I can't get it to rotate properly... I want the camera to always look at the terrain from above, of course. Also note that the player controls an airplane that can adjust its pitch, and can also fly upside-down if rotated enough.

I'm currently using this code for the mini-map camera:

 #pragma strict
 
 var minimapTarget : Transform;
 var smooth : float = 3;
 
 function Start () {
 
 }
 
 function Update () {
 
     transform.position.x = Mathf.Lerp( transform.position.x, minimapTarget.position.x, Time.deltaTime*smooth );
     transform.position.z = Mathf.Lerp( transform.position.z, minimapTarget.position.z, Time.deltaTime*smooth );
     
 }

How can I get this to rotate with 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
Best Answer

Answer by HolBol · Nov 14, 2012 at 12:15 AM

Why not set the camera's transform.rotation.z to be equal to the target's? That could work.

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 Seth-Bergman · Nov 14, 2012 at 12:28 AM 0
Share

hmm, probably the y, I think, rather than z.. You COULD simply add this line:

 transform.rotation.eulerAngles.y = $$anonymous$$imapTarget.rotation.eulerAngles.y;

that WOULD work, UNLESS the object goes upside down..

which we know it might.. SO it's a bit more complicated..

avatar image HolBol · Nov 14, 2012 at 02:21 AM 0
Share

Good point, I did mean Y. That's what too.much time in blender does to you.

avatar image
1

Answer by m4s4m0r1 · Nov 14, 2012 at 12:33 AM

Create new Camera and Set this Script to your new Camera

 var target : Transform;
 var distance : float;
 var height : float;
 var damping :float;
 var rotDamp : float;
 function LateUpdate () {
 var wantedPosition = target.TransformPoint(0,height,-distance);
 transform.position = Vector3.Lerp(transform.position,wantedPosition,Time.deltaTime*damping);
 
 var wantedRotation = Quaternion.LookRotation(target.position - transform.position,target.up);
 transform.rotation = Quaternion.Slerp(transform.rotation,wantedRotation,Time.deltaTime*rotDamp);
 
 }

after that, you can adjust your own setting to this camera...

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

12 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 avatar image

Related Questions

Quaternion Slerp Sanity Check 1 Answer

How to freeze the rotation or the position on the camera transform? 1 Answer

how do i make first person character rotate left and right along with camera? 0 Answers

Override Oculus Orientation 5.3 1 Answer

How to make the camera rotate only when right click is held down on the mouse? 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