Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 shakti_patra · May 22, 2018 at 05:21 PM · cameracamera-movementcamera followcamera movementcameras

How to make a camera Follow an Object moving in zigzag path?

I have a sphere which is moving upwards in zigzag path. I want my camera to follow the zigzag object. When I am setting the "adding offset value to player position option" method, it is not showing me the zigzag effect as I am setting the player.position.y = camera.position.y. please 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 MT369MT · May 22, 2018 at 05:47 PM 0
Share

Hi, I think you must also set the x position of the camera the same as the x player position.

avatar image shakti_patra MT369MT · May 22, 2018 at 06:39 PM 0
Share

Hi, I want to achieve this https://answers.unity.com/questions/1509391/camera-follow-gameobject-moving-in-angular-path.html

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by NoDumbQuestion · May 23, 2018 at 10:08 AM

5 minute solution. Not tested:

All you have to do is have an value that respresent zig zag value that increase as player move. When get too high, starting to decrease to lower, when too low, start to rise value. Add that value to Camera position

 public Camera myMainCamera;

 public float zigzagWidth = 5f; // must be positive

 private float currentZigZagPos = 0;

 public void MainPlayerMoveDistance(float deltaMove)
 {
     float offset = 0;
     var pos = myMainCamera.transform.position;

     currentZigZagPos += deltaMove;
     if (currentZigZagPos > zigzagWidth)
     {
         offset = currentZigZagPos - zigzagWidth;
         currentZigZagPos = zigzagWidth;
     }
     else if(currentZigZagPos < -zigzagWidth)
     {
         offset = currentZigZagPos + zigzagWidth;
         currentZigZagPos = -zigzagWidth;
     }
     // X or Y axis whatever
     pos.x += deltaMove - offset;
     myMainCamera.transform.position = pos;
 }

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 Harinezumi · May 23, 2018 at 10:12 AM 0
Share

$$anonymous$$athf.Pingpong() is extremely useful in this case ;)

avatar image NoDumbQuestion Harinezumi · May 23, 2018 at 10:23 AM 0
Share

Well well. Unity doc is full of unknown. Good to know

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

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

Make a camera to Follow two players 2 Answers

Smooth camera on moving platform 1 Answer

Help make camera zoom smoother 3 Answers

Camera not following Player 1 Answer

Camera Follow (Not Exact) 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