Advertisement

Holistering and unholistering gun?

Started by October 14, 2016 04:03 PM
7 comments, last by tronado711 8 years, 1 month ago

One thing I've been trying to figure out lately is how to do a proper gun holster system in my game. In most of my games, from what I've seen when you holister a gun you pull it out and hold it and obviously the holster is left empty. However, as many can tell, in some games when you pick up an object, it sort of teleports a few inches, snapping perfectly into the npc model's hands. My question is how is a holister system done in the game? Does it perform sort of an eye trick where it instantly swaps models to one with a gun as an object attached to his hands or does the object become like attached to his hands real time in the game?

-Matt

And lead us not into frustration; but deliver us from GOTOs. For thine is algorithm, the computation, and the solution, looping forever and ever.

Return;

Most first-person shooting games: if the hand is seen without the gun, then the hand moves down
offscreen and returns holding the gun. If the hand needn't be shown when not holding a gun, then when
the gun is equipped, the hand just comes up from below screen holding the gun.
But you mentioned an NPC. For an NPC, there needs to be a drawing-the-gun animation.

Edit: This is a programming forum. Is your question about programming?

-- Tom Sloper -- sloperama.com

Advertisement

Most first-person shooting games: if the hand is seen without the gun, then the hand moves down
offscreen and returns holding the gun. If the hand needn't be shown when not holding a gun, then when
the gun is equipped, the hand just comes up from below screen holding the gun.
But you mentioned an NPC. For an NPC, there needs to be a drawing-the-gun animation.

Edit: This is a programming forum. Is your question about programming?

I'm referring to say a third person shooter. Let's say an npc takes out a gun from a holster and keeps carrying it. What's the programming side to that? Like how does it stay attached to their hands? I'm saying is this achieved through programming or 3d modelling. Not the animation of pulling the gun out, but the concept of the gun, staying in the hand and moving smoothly with the animations of the npc. Is this achieved through 3d modelling or programming? Because in 3d animation, getting a totally separate object to animation in perfect sync with another (the two objects being the npc and the gun) would be extremely difficult. So how is it achieved that when unholister, the gun stays perfectly attached to the hand? Is there perhaps a script in the game engine that keeps the model attached at a certain point to the hand?

And lead us not into frustration; but deliver us from GOTOs. For thine is algorithm, the computation, and the solution, looping forever and ever.

Return;

I can tell you how I did this in my rpg.

The player has an empty hand and the sword is attached to the hand via a bone attachment. It then moves with the animation and when the player character swipes their hand the sword swipes too.

When they sheath it, it is attached to a bone attachment at the hip, where the scabbard is.

The trick is making the animations line up.

Hope this helps!

Edit: here's an example of an early test of it:

I can tell you how I did this in my rpg.

The player has an empty hand and the sword is attached to the hand via a bone attachment. It then moves with the animation and when the player character swipes their hand the sword swipes too.

When they sheath it, it is attached to a bone attachment at the hip, where the scabbard is.

The trick is making the animations line up.

Hope this helps!

Edit: here's an example of an early test of it:

Ahh bone attchments! Okay that makes sense! So are the bone attachments made in the modelling program itself. I know the bones are. Or are the bone attachments scripted up in the games scripting engine?

And lead us not into frustration; but deliver us from GOTOs. For thine is algorithm, the computation, and the solution, looping forever and ever.

Return;

The bone attachments are known as sockets in UE4.

You can place them in the editor.

I'm not sure if you can place them in a 3D modelling program or not but that would make sense as it's really something for a modeler to do, not a programmer...
Advertisement

The bone attachments are known as sockets in UE4.

You can place them in the editor.

I'm not sure if you can place them in a 3D modelling program or not but that would make sense as it's really something for a modeler to do, not a programmer...

I'm looking up how to do it in Unity and there's a script for attach objects via a bone. However, I know you can use bone attachments for objects in 3DS MAX and Blender. The only thing would be properly implementing them into the game since UNITY from the way it seems expects you to do it their way. But that is a problem for another day. Thank you so much for your help!! :)

And lead us not into frustration; but deliver us from GOTOs. For thine is algorithm, the computation, and the solution, looping forever and ever.

Return;

I'm looking up how to do it in Unity and there's a script for attach objects via a bone. However, I know you can use bone attachments for objects in 3DS MAX and Blender. The only thing would be properly implementing them into the game since UNITY from the way it seems expects you to do it their way. But that is a problem for another day. Thank you so much for your help!! :)


If I were setting up such a system in unity I would create an attachment point script and a attachment point group script

AttachmentPoint.cs

using UnityEngine;

class AttachmentPoint : MonoBehavior {
    public string name;

    void Start() {
        AttachmentPointGroup group = gameObject.GetComponentInParent<AttachmentPointGroup>();
        group.Add(this, name);
    }
}
AttachmentPointGroup.cs

using UnityEngine;
using System.Collections.Generic;

public AttachmentPointGroup : MonoBehavior {
    private Dictionary<string, AttachmentPoint> attachmentPoints = new Dictionary<string, AttachmentPoint>();

    public void Add(AttachmentPoint point, string name) {
        attachmentPoints[name] = point;
    }

    public void Get(string name) {
        return attachmentPoints[name];
    }
}

You add the AttachmentPointGroup on the root element of your character's game object. Then you add AttachmentPoint scripts to any bone you wish to attach things to. The string name lets you specify unique names for each attachment point. You can then get the AttachmentPointGroup component whenever you want to attach things to the hands/head/torso ect.
My current game project Platform RPG

I'm looking up how to do it in Unity and there's a script for attach objects via a bone. However, I know you can use bone attachments for objects in 3DS MAX and Blender. The only thing would be properly implementing them into the game since UNITY from the way it seems expects you to do it their way. But that is a problem for another day. Thank you so much for your help!! :)


If I were setting up such a system in unity I would create an attachment point script and a attachment point group script

AttachmentPoint.cs

using UnityEngine;

class AttachmentPoint : MonoBehavior {
    public string name;

    void Start() {
        AttachmentPointGroup group = gameObject.GetComponentInParent<AttachmentPointGroup>();
        group.Add(this, name);
    }
}
AttachmentPointGroup.cs

using UnityEngine;
using System.Collections.Generic;

public AttachmentPointGroup : MonoBehavior {
    private Dictionary<string, AttachmentPoint> attachmentPoints = new Dictionary<string, AttachmentPoint>();

    public void Add(AttachmentPoint point, string name) {
        attachmentPoints[name] = point;
    }

    public void Get(string name) {
        return attachmentPoints[name];
    }
}

You add the AttachmentPointGroup on the root element of your character's game object. Then you add AttachmentPoint scripts to any bone you wish to attach things to. The string name lets you specify unique names for each attachment point. You can then get the AttachmentPointGroup component whenever you want to attach things to the hands/head/torso ect.

I'll save this snippet into Visual Studio, for later use! Thank you!

And lead us not into frustration; but deliver us from GOTOs. For thine is algorithm, the computation, and the solution, looping forever and ever.

Return;

This topic is closed to new replies.

Advertisement