A
A
AntiLockYT2020-05-04 19:15:52
C++ / C#
AntiLockYT, 2020-05-04 19:15:52

Why is the camera in Unity3D to the left of the character?

I attached the camera to the player, and it is to the left of him! The character is to the right of the camera! And I need it to be in the middle!
Here is the script for the camera

using UnityEngine;

public class CamMove : MonoBehaviour
{

    public GameObject player;
  
    void Update()
    {
       transform.position = new Vector3 (player.transform.position.x, player.transform.position.y,-10f);
    }
}

Here is the character movement script
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Controller : MonoBehaviour
{
    int speed = 2;
  int jump = 10;
  Rigidbody2D rb;
    void Start()
    {
        rb = GetComponent<Rigidbody2D>();
    }

    // Update is called once per frame
    void Update()
    {
        rb.velocity = new Vector2(Input.GetAxis("Horizontal") * speed, rb.velocity.y);
    
      if (Input.GetKeyDown (KeyCode.Space))
      rb.AddForce (Vector2.up * 125);
    }
  
}

Here's the unit
5eb03f4bd3fb3453843450.png
I need it like this
5eb03f716f155445617829.png
And it's like this
5eb03f9b428c6824466628.png

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question