Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

How to 'pick up object when reference to prefab Player is in inspector'?

Discussion in 'Getting Started' started by larjun, Dec 4, 2021.

?

Is one instantiated player in each scene best instead of using a prefab player via the inspector

  1. yes

    0 vote(s)
    0.0%
  2. no

    0 vote(s)
    0.0%
  1. larjun

    larjun

    Joined:
    Feb 20, 2017
    Posts:
    3
    Hi!
    My game is based on a unity demo game that I copied not directly but the idea of how create objects/enemies.
    The idea of having a player instantiated via LevelManager and via a PlayerManager class that creates a PlayerController class does not seem so smart. (Enemies could be that way).
    But with Player you need to access, for example, a hand (HingeJoint) to connect a weapon to the hand. This is not easy with a Player prefab. Have look and have not find any good solution. Remember a long time ago one solution with joints in placed both in search object and in searcher. When this two object come together (via OnTriggerEnter and colliders) I can dock them together and (with som direction solution) then get the objetct in his hand!
    Has placed object PlugIn under RightHand in the HingeJoint chain in Players rig.
    Has inserted PlugIn1 in the object to be picked up.
    Assigns the GameObject Transform PlugIn = PlugIn1. PlugIn1.transform.position = PlugIn.transform.position; PlugIn.transform.parent = PlugIn.transform; // makes the object become a child of the parent so it moves when hand moves with it .


    Does it not work?