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 ShadowBlades1 · Jan 14, 2015 at 08:07 PM · camera-movementcamera rotate

Camera Rotation and Movement (Moving between two positions)

I've seen a lot of these posts and none really seem to cover what I need help with. For the record I've just started working with unity.

Basically I completed unity's ball game tutorial and wanted to expand upon it. I made a 'level' for the player to finish. There is a part where the player must navigate over a pole type object and it's really hard to see from the current following camera.

I want to switch the camera from it's "normal" position to a "top down" view.

I have created a trigger and a link between the player and the camera so when the player hits the trigger, a bool changes in the camera script. Effectively making a toggle.

From the player script:

     if (otherObject.gameObject.tag == "TopDownCameraTrigger")
     {
         //GameObject.FindWithTag(tag name).GetComponent<.cs files name>().name of method ();
         //The link between player interaction and telling the camera is should move
         GameObject.FindWithTag ("MainCamera").GetComponent<CameraControler>().ToggleIsMoved();
     }


From the camera script:

     public void ToggleIsMoved()
     {
         // A glorified switch statement used to toggle camera movement
         if(isMoved == true)
         {
             isMoved = false;
             MoveToNormal();
             print ("Triggered Wall To False");
         }
         if(isMoved == false)
         {
             isMoved = true;
             MoveToTopDown();
             print ("Triggered Wall To True");
         }
         currentTime = 0.0f;    //This will 'reset' the timer, allowing the camera to move again.
     }




Now I have two methods, MoveToTopDown() and MoveToNormal()

The idea is that when the player hits the box collider, it will call ToggleIsMoved() Then the bool will switch and also reset the timer (allowing the camera to move). Based on the bool (t/f) the camera will begin to move towards its respective position for some time(maxTime)

The question is: How?

I think I want to store both normal, and top down positions as transforms, so I can have access to both position and rotation, however, I am unsure.

I guess you could also store the position and rotation separately and have two motions going on at the same time, that would also work fine.

Here is an idea of the functions:

 public void MoveToTopDown()
 {
                                         //current position                    final position                        speed variable
     transform.position = Vector3.Lerp ((transform.position + offset), (topDownPosition.position + offset), camMoveSpeed * Time.deltaTime);

     transform.rotation = Vector3.Lerp (transform.rotation, topDownPosition.rotation, camMoveSpeed * Time.deltaTime);
 }

MoveToNormal is essentially the same.

Also, the offset is so that the camera stays a certain distance from the player.

Any help would be great! Many thanks!

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 DanSuperGP · Jan 15, 2015 at 12:34 AM 0
Share

I like placing empty game objects as children of the thing being followed to represent the positions, with a gizmo added to help find it in the scene view. Then if you want to adjust their positions, you're moving around actual game objects ins$$anonymous$$d of just tweaking numbers.

0 Replies

· Add your reply
  • Sort: 

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Lean/Peak system 1 Answer

Roll a ball camera with rotating by a mouse? 1 Answer

Camera stucks at the spawn position 1 Answer

Allow both turning of the mouse and turning of the player to keep the camera pointing towards the player 1 Answer

How to orbit camera around player from top-down to sidescroller view? 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