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 to move Main Camera without moving its children?

Discussion in 'Scripting' started by androidac67, May 16, 2023.

  1. androidac67

    androidac67

    Joined:
    Jan 3, 2023
    Posts:
    75
    I have my first person camera separate from the player and I have my players "hands" (or even gun, etc) object as a child of the camera. When I move the camera itself in the inspector, the hands move with it.

    Is there any way to prevent this from happening unless I want it to? Because right now I've been adding head/view bobbing and I'm trying to make only my Main Camera move.

    Currently I have my empty "Camera Holder" game object, with my Main Camera as a child of it, then my "Hands" object as a child of my Main Camera. Is it my implementation of my camera that is preventing me from getting the result I want?
     
  2. spiney199

    spiney199

    Joined:
    Feb 11, 2021
    Posts:
    5,769
    You would want to make the camera and hands, gun, etc, all siblings, rather than the latter the child of the former.

    That way you can rotate the parent object of both to move both camera and hands, while also being able to move the camera on top of that, without moving the hands.
     
    Yoreki likes this.
  3. androidac67

    androidac67

    Joined:
    Jan 3, 2023
    Posts:
    75
    How would you make them all siblings? Just place everything in an empty game object but keep them unparented to one another (beyond the empty game object)?
     
  4. spiney199

    spiney199

    Joined:
    Feb 11, 2021
    Posts:
    5,769
    More or less. Game objects that are all children of the same transform are considered 'siblings'.
     
  5. orionsyndrome

    orionsyndrome

    Joined:
    May 4, 2014
    Posts:
    3,043
    - what do you do for living?
    - when I'm not unparenting characters I might occasionally reorder their siblings or destroy some of their children
    - ...