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).
using UnityEngine;
using System.Collections;
public class CameraController : MonoBehaviour
{
public GameObject player;
private Vector3 offset;
void start ()
{
Vector3 offset = new Vector3(transform.position.x, transform.position.y, transform.position.z);
}
void LateUpdate ()
{
transform.position = player.transform.position + offset;
}
}
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.
1519883–86877–$Roll A Ball.rar (75.6 KB)