• 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 cat_dawg · May 09, 2021 at 05:54 AM · camerarotationsphere

Roll-a-Ball Tutorial Camera still doing loop de loop as it follows the sphere.

Hi everyone. I followed the exact steps for the Roll-a-Ball tutorial and I was able to affix my camera to the sphere but it is still doing a rotation (a vertical rotation around the z-axis) as I'm moving the sphere. I am using a prefab of a beach ball I downloaded from the assets store, could some setting in there be affecting it?

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 GSGregory · May 09, 2021 at 06:01 AM 0
Share

How are you doing the following? Is the camera a child object?

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by cat_dawg · May 10, 2021 at 04:56 PM

Hi @GSGregory! No, I didn't make it a child object. The camera is its own game object with a camera controller script attached. The following script is directly from Unity's tutorial on YouTube.


public class CameraController : MonoBehaviour { public GameObject player;

 private Vector3 offset;
 void Start()
 {
     offset = transform.position - player.transform.position;
 }

 // Update is called once per frame
 void Update()
 {
     
 }
 void LateUpdate()
 {
    transform.position = player.transform.position + offset;
     
 }




Comment
Add comment · Show 7 · 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 GSGregory · May 10, 2021 at 06:11 PM 0
Share

Hmm. I'm looking at the tutorial currently and trying to figure out what the issue is. In the meantime this is the script I currently use to manage my own camera.

 {
     public GameObject target;
     public Vector3 offset;
     public Transform targetTransform;
     public float offsetMax = 20f;
     public float offsetMin = 10f;
 
 
     // Update is called once per frame
     void LateUpdate()
     {
         transform.position = target.transform.position + offset;
         transform.LookAt(targetTransform);
 
         if (Input.mouseScrollDelta.y > 0 && offset.y < offsetMax)
         {
             offset.y += Input.mouseScrollDelta.y;
         }
 
         if (Input.mouseScrollDelta.y < 0 && offset.y > offsetMin)
         {
             offset.y += Input.mouseScrollDelta.y;
         }
     }
 }
 


Btw, what is the offset set to?

avatar image GSGregory · May 10, 2021 at 06:51 PM 0
Share

Can you link to the beachball you used?

avatar image cat_dawg GSGregory · May 10, 2021 at 07:49 PM 0
Share

Yes, of course! I got it from the Assets store.

https://assetstore.unity.com/packages/3d/props/free-beach-essentials-asset-pack-131149

Thank you so much for your help so far. I'm completely brand new to this!

I apologize if I answer thing in the wrong terms:

If by offset, do you mean the difference between the player's position and the camera's position...could I answer that by listing the vectors? I don't think I have offset set to anything... The position of my object is (-323, 70, -49), the camera is (-323, 89, -68) rotated at 45 degrees on the x-axis.

avatar image cat_dawg cat_dawg · May 10, 2021 at 07:57 PM 0
Share

I also tried your script without messing with any values and it's still doing that weird rolling motion as I move the ball. So strange!

Show more comments

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

205 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 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

How do i lock the position of the camera above the player relative to the origin point? 0 Answers

Rotating following camera for a sphere 1 Answer

Camera And player rotation 0 Answers

Third person follow camera on a sphere 1 Answer

"Free" rotation about a sphere 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