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 /
  • Help Room /
avatar image
0
Question by XxEverlifeXx · Aug 25, 2015 at 02:54 PM · scripting problemcamera rotatecamera followroll a ball

Why is my camera rolling around like a ball?

I'm new to unity, I'm trying to figure out how to do the rolling ball tutorial game to start off, and the next lesson I'm learning is how to make the camera follow the ball. I put the camera as a "child" of the player object (the ball) and when I hit play to see if the camera followed my ball, I found out that it did... way too well. The camera rolls like the ball does so the entire camera screen is rotating and spinning and frankly makes me feel a bit sick watching it. Is this because in my script the ball rolls, so making the camera a child of the ball makes the camera roll too? I can't figure out how to fix this nonsense and I need to to continue learning unity :/

here is the tutorial i'm using: https://unity3d.com/learn/tutorials/projects/roll-a-ball/moving-the-camera?playlist=17141

Here is my script attached to my player: using UnityEngine; using System.Collections;

public class PlayerController : MonoBehaviour { public float speed; private Rigidbody rb;

 void Start (){
     rb = GetComponent<Rigidbody> ();
 }

 void FixedUpdate () {
     float moveHorizontal = Input.GetAxis ("Horizontal");
     float moveVertical = Input.GetAxis ("Vertical");

     Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical);

     rb.AddForce (movement * speed);
 }

}

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

3 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by Taorcb · Aug 26, 2015 at 08:45 AM

To elaborate on the "it rolls because it's a child of the ball" answer: If you set a GameObect to be a child of another GameObject, the child's position will always be the same, relative to it's parent's position. I would use a transform.LookAt() function to keep the camera stable, but the tutorial you're doing will cover that.

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

Answer by AtticRoomBoy · Aug 25, 2015 at 03:14 PM

The Roll a Ball tutorial does show you how to write a script to fix this.

The reasons the camera rolls around like this is because it is a child of the ball.

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

Answer by SuperRaed · Aug 25, 2015 at 07:35 PM

Like AtticRoomBoy said having it as a child is causing it to roll along with the ball and I know what's that like as I fell for the same mistake. why don't you try to set the transform.position for your camera as the ball.transform.position? but keep in mind to keep a distance vector 3 variable so that with each frame update the camera position would be

 void FixedUpdate(){
 transform.position = balls.transform.position+ difference.position 
 
 
 }
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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Third person controller camera 1 Answer

How to smooth change to a different camera position when still following the player?,How to smooth change my camera position when still following the player? 0 Answers

Camera Roll/Headbob? 0 Answers

How to fix player camera shaking 0 Answers

How to make my camera follow the ball smoothly, because when the players touch the camera is not really stable 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