My code isn’t working how I want it to. I want it to move the camera to PositionMover’s location when the player walks into PositionMover’s Collider, but it’s not working. Here is the code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CameraBoundries : MonoBehaviour
{
public GameObject Camera;
public GameObject NextArea;
public CameraFollowPlayer CameraFollow;
public void OnCollisionExit2D(Collision2D dataFromCollision)
{
if (dataFromCollision.gameObject.name == "2")
{
CameraFollow.enabled = false;
}
}
public void OnCollisionEnter2D(Collision2D dataFromCollision)
{
if (dataFromCollision.gameObject.name == "PositionMover")
{
Camera.transform.position = NextArea.transform.position;
}
if (dataFromCollision.gameObject.name == "2")
{
CameraFollow.enabled = true;
}
}
}
Also, my sprite looks weird. If you can fix that as well, that would be helpful.
Should
Shouldn’t
They are sliced if that is a problem.