Search Unity

Roll-A-Ball camera tutorial problem

Discussion in 'Scripting' started by Nightwind, Feb 14, 2014.

  1. Nightwind

    Nightwind

    Joined:
    Feb 14, 2014
    Posts:
    1
    Was playing around with RPG MakerVxAce for a while but decided to step up to a 3D engine. I feel I have a decent beginner's grasp on using Unity and the very basics of scripting. I followed the Space Shooter tutorial and it turned out great. Now I'm following the Roll-A-Ball tutorial and have run into a problem.

    Lesson 4 explains how to attach the camera to the Ball so it follows it around the plane, but doesn't roll with the ball. As far as I can tell, I've followed the instructions and script to a T...but the camera basically resets to (and follows) the origin of the ball as it moves around. The 'Main Camera' initial transform is set at 0, 10, -10 and rotation 45, 0, 0 (per the tutorial). If I deactivate just this script on the 'Main Camera' I can view the board statically as per the previous lesson. My best guess is the script is somehow not grabbing/adding this initial transform and just mirroring the ball/player's transform info.

    Here is my script for the CameraController. As explained in the tutorial, I made sure the camera is one it's own and not a child of the ball (player).

    Code (csharp):
    1.  
    2. using UnityEngine;
    3. using System.Collections;
    4.  
    5. public class CameraController : MonoBehaviour
    6. {
    7.     public GameObject player;
    8.     private Vector3 offset;
    9.  
    10.     void start ()
    11.     {
    12.         Vector3 offset = new Vector3(transform.position.x, transform.position.y, transform.position.z);
    13.     }
    14.  
    15.     void LateUpdate ()
    16.     {
    17.         transform.position = player.transform.position + offset;
    18.     }
    19. }
    20.  
    Let me know if you need any more info. I attached a RAR'd copy of my game as well. Any help would be much appreciated.
     

    Attached Files:

  2. ABagOfBabySeals

    ABagOfBabySeals

    Joined:
    Dec 18, 2014
    Posts:
    1
    I doubt you still care but if anyone else has this problem its because your void Start doesn't have a capital "s" I did the same thing.