Jump to content
  • Advertisement
Sign in to follow this  
tronado711

Holistering and unholistering gun?

This topic is 644 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
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? Edited by Tom Sloper

Share this post


Link to post
Share on other sites

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?

Edited by tronado711

Share this post


Link to post
Share on other sites
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:

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites
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...

Share this post


Link to post
Share on other sites

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!! :)

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

 

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!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!