Home General Discussion

Using Socket in Unity

So not really sure how to explain this but I know that in Unreal they have something called sockets which for example let you connect different guns to different characters. all at the same point so that it properly fits in to the characters hand. So my question is how to basically do the same workflow in Unity. What is it called in Unity, any links to tutorials would help. Even programming help would be appreciated.

Replies

  • MikeF
    Offline / Send Message
    MikeF polycounter lvl 20
    Since Unity isnt specifically targeted towards shooters i dont believe there is an equivalent (at least if i'm understanding what you want here). The easiest way to do this would be to set up a dummy object in your modeling software, parent this to the hand and give it an identifiable name like "Gun_Locator".

    Then you'd write a script along these lines:

    ////////////////////////////////
    var GunLocator : Transform;
    var Gun : Transform;

    function Start()
    {
    Gun.transform.parent = GunLocator;
    Gun.transform.localPosition = Vector3(0,0,0);
    }
    ///////////////////////////////

    Attach the script to your character, Assign your gun mesh to the Gun var, and the dummy object to GunLocator.
Sign In or Register to comment.