Hi, I have this game with a bird where you can move freely in the sky, but at one moment you enter a boss fight and the camera freezes. My problem is the fact that the bird ca still go beyond the bounds of the camera…
Here is the movement script :
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Bird_JackeySCR : MonoBehaviour
{
public float MaxSpeed = 10;
public bool CanMove;
// Start is called before the first frame update
void Start()
{
CanMove = true;
MaxSpeed = 10;
}
// Update is called once per frame
void Update()
{
if (CanMove)
{
Vector3 pos = transform.position;
pos.y += Input.GetAxis("Vertical") * MaxSpeed * Time.deltaTime;
pos.x += Input.GetAxis("Horizontal") * MaxSpeed * Time.deltaTime;
transform.position = pos;
}
}
private void OnCollisionEnter2D(Collision2D collision)
{
if(collision.gameObject.tag == "Edges")
{
CanMove = false;
}
}
private void OnCollisionStay2D(Collision2D collision)
{
if (collision.gameObject.tag == "Edges")
{
CanMove = false;
}
}
private void OnCollisionExit2D(Collision2D collision)
{
if (collision.gameObject.tag == "Edges")
{
CanMove = true;
}
}
}
Also the bird doesnt have collision when It should have i dont know why but it doesnt detect any collision at all no matter how I do it trigger or not …
Any hep would be very appreciated, take care y’all!