Search Unity

  1. If you have experience with import & exporting custom (.unitypackage) packages, please help complete a survey (open until May 15, 2024).
    Dismiss Notice
  2. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice

CameraControl script, not working.

Discussion in 'Scripting' started by QuA5aR_17, Jul 23, 2014.

  1. QuA5aR_17

    QuA5aR_17

    Joined:
    Jul 22, 2014
    Posts:
    11
    Ive tried doing this over and over again in different scripts and it still doesnt work. The ball and the camera, together, fly off the screen and i can't control it. I don't know what's wrong with it. Screenshot (1).png
     
  2. KheltonHeadley

    KheltonHeadley

    Joined:
    Oct 19, 2010
    Posts:
    1,685
    Belongs in Scripting.
     
  3. QuA5aR_17

    QuA5aR_17

    Joined:
    Jul 22, 2014
    Posts:
    11
    what do i need to do
     
  4. KheltonHeadley

    KheltonHeadley

    Joined:
    Oct 19, 2010
    Posts:
    1,685
    Stop posting in Gossip.
     
  5. Arowx

    Arowx

    Joined:
    Nov 12, 2009
    Posts:
    8,194
    For this to work the player object has to start at position 0,0,0 and the camera has to be setup where you need it.

    If not you will have to calculate the offset by taking the cameras position away from the players position (or visa versa).

    You should store the player Transform not it's game object, as this is a better practice to get into when you only need the position, not the full gameObject.

    The camera should follow the ball.
     
    Last edited: Jul 23, 2014
    QuA5aR_17 likes this.
  6. QuA5aR_17

    QuA5aR_17

    Joined:
    Jul 22, 2014
    Posts:
    11
    thank you, but im a noob at this, and i have little to no idea of what your talking about but i tried some of what you said and it stopped flying away. but it still wont work. i want to have the ball role without the camera rolling with it. but thanks for trying. i will tell u if i figure it out.
     
  7. QuA5aR_17

    QuA5aR_17

    Joined:
    Jul 22, 2014
    Posts:
    11
    so i will need to do
    public Transform player;
    before i did
    public GameObject player;
    ?
     
  8. Arowx

    Arowx

    Joined:
    Nov 12, 2009
    Posts:
    8,194
    Just use a camera follow script, Assets -> Import Package -> Scripts.
     
  9. QuA5aR_17

    QuA5aR_17

    Joined:
    Jul 22, 2014
    Posts:
    11
    i cant find the import package
     
  10. Arowx

    Arowx

    Joined:
    Nov 12, 2009
    Posts:
    8,194
    Is your camera a child object of the ball? The ball and camera should be separate objects. Updating the cameras position should not cause the camera to roll.
     
    JoshaEiffel likes this.
  11. landon912

    landon912

    Joined:
    Nov 8, 2011
    Posts:
    1,579