So I’m trying to make a game that only moves the camera to a certain spot when you reach a certain point, I’m doing this by making a trigger wall between each stage that should move the camera, but I’m new and don’t know how to move the camera without having it follow the player. I thought I could use a public variable that moves the camera when turned true, but 1. the variable was apparently invalid, and 2. I don’t know what to write to move it. Here are my scripts: using UnityEngine;
using System.Collections;
public class PlayerController : MonoBehaviour
{
public int cm;
public float speed;
private Rigidbody rb;
void Awake()
{
cm = 0;
}
void Start()
{
rb = GetComponent<Rigidbody>();
}
void FixedUpdate()
{
float moveHorizontal = Input.GetAxis("Horizontal");
Vector3 movement = new Vector3(moveHorizontal, 0.0f, 0.0f);
rb.AddForce(movement * speed);
}
void OnTriggerEnter(Collider other)
{
if (other.gameObject.CompareTag("Pick Up"))
{
other.gameObject.SetActive(false);
cm = 1;
}
}
}
The cm is the public variable that should go to one when I want to move the camera, and it is turned to that when I pick up the transition block. (Transition block works just fine)
Then, I programmed this to move the camera:
using UnityEngine;
using System.Collections;
public class CameraController : MonoBehaviour {
// Use this for initialization
void Start () {
int moveHorizontal = 10;
}
// Update is called once per frame
void Update () {
if(cm > 0)
{
transform.position(10.0f, 0.0f, 0.0f);
}
}
}
}
Here you can see that if cm is greater than one, which happens when transition happens (it works I looked on the side) but it tells me cm doesn’t exist. Also, I get the error that transform.position(10.0f, 0.0f, 0.0f);
doesn’t exist.
Any help?