Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question How can I move camera with an entity's moving?[Solved]

Discussion in 'Entity Component System' started by iamshenkui_gee, Jun 29, 2022.

  1. iamshenkui_gee

    iamshenkui_gee

    Joined:
    Apr 24, 2021
    Posts:
    30
    I spawn my player from subscene, and I was wondering how can I move the camera to make the player at the center of the game?
     
  2. Arnold_2013

    Arnold_2013

    Joined:
    Nov 24, 2013
    Posts:
    262
    Get the player entity transform (position + rotation) and set the camera transform to these values (or with an offset). While in the main thread part of a system OnUpdate() you can access 'normal unity' gameObjects and get/set their values/
     
    bb8_1 and iamshenkui_gee like this.
  3. iamshenkui_gee

    iamshenkui_gee

    Joined:
    Apr 24, 2021
    Posts:
    30
    Thank you, I got it