Hey there, I’m Mel.
This is my first time using Unity, and I’ve just completed the Roll-a-Ball game tutorial I’ve found on Youtube, which came just in handy for a little game I was trying to put together. My only problem is, when I try to customize the scripts used in the tutorial to fit my needs a bit more, namely the camera, I get completely stuck.
Here’s the script:
using UnityEngine;
using System.Collections;
public class CameraController : MonoBehaviour {
//Visible, invisible in the menus / Variable Type / Variable name
public GameObject player;
private Vector3 offset;
//GameObject is for which game object to assign as the player
//Vector3 refers to the three axises
// Use this for initialization
void Start () {
offset = transform.position - player.transform.position;
}
// Update is called once per frame
void LateUpdate () {
transform.position = player.transform.position + offset;
}
}
(yes i make notes for myself so i don’t get confused)
Right now, the camera follows the rolling ball perfectly behind it, however, all I want to do is the make it stop moving vertically, meaning if the ball goes left or right, the camera would not follow it just from the center of the track. I tried to look up on something that might help in the documentation but I don’t even know what I should be looking for.
I know this might be a stupidly easy thing for some of you here, but for me, this is a bit of getting thrown into deep water. Any help is appreciated.