Hello,
I am a beginner to the Unity and the C# and I am trying to make a very simple casual game. There will be a bird fying and collect gold coins. The background has a parallax effect. I add a 2D rigitbody and a Box Collider on the bird. Then I used the script below to force on the bird so it will be flying continiously to the right:
public float speed = 2;
public float force = 300;
// Start is called before the first frame update
void Start()
{
GetComponent<Rigidbody2D>().velocity = Vector2.right * speed;
}
Then I used this simple coding to the camera, so it will follow the bird continuously;
public Transform Kus;
private void LateUpdate()
{
transform.position = new Vector3((float)(Kus.position.x + 7.7), Kus.position.y, Kus.position.z);
}
The problem is, when I use this, the is dissapearing from the game screen. If I deactivate the code for camera, The bird is on the screen and it is fliying to right and the camera stands still. If I activate the camera, bir flies to the right and camera is following it but the bird is dissepearing from the game screen. You can see the example image below:
How can I solve this problem? What is I have been doing wrong? (PS: There is no problem with Bird’s layer, bacause as I said, when I cancel the camera moving script, it is on the screen and flying to the right.)
Thank you very much for your help in advance