Jump to content

Adding new guns to 7 Days to Die (A17)


KhaineGB

Recommended Posts

I figured the tutorial for adding guns to the game needed updating, especially since things have changed in A17. If you don't have your prefab setup correctly, you'll be presented with NRE's upon trying to equip your new gun.

 

So I did a tutorial thing!

 

 

Hopefully it'll be of use to folks. :)

Link to comment
Share on other sites

Thx alot for this tutorial :D Been wanting to add a custom model to the rifle I made before releasing it. Tried making the exact same thing as you did first tho ,just to see ifI got it working, but keep getting NRE's when trying to equip it. I did the attachments same way as you did in the video, and did exactly the same edits in the xml aswell. Only thing different was I couldnt find the prefan gun with the flashlight attached, so use the PistolPrefab extracted with Asset Studio instead. But that shouldnt have any effect on the result? Except possibly scale/orientation?

Link to comment
Share on other sites

If you're getting an NRE when trying to equip it, then I absolutely guarantee you're missing the Attachments/Scope transform (and yes, the capitilization MATTERS).

 

Try disabling action1 for the gun in your XML. If it stops giving NRE's, that's your problem. You didn't set up the scope object correctly.

Link to comment
Share on other sites

I checked that first thing actually, since you were pretty clear on that in the video, which is a good thing or I might just aswell have missed it :)

 

Still, commenting out action1 did work. it shoots and all, but what I'm actually holding in my hand looks like a piece of cloth or leather :D

(Your assumptions that people watching your video were familiar with Unity editor is not applicable in all cases lol). I know I should be before using it, but looked so easy based on your tutorial :)

 

576541803_Annotation2018-12-30224524.thumb.jpg.75d35a3d74f6bfe788a202bf98bf857f.jpg

 

Edit: Also, when looking at the huntingrifle prefab extracted from the games assets folder, I dont see all the attachment points I would assume based on the attachments the gun supports. But as long as I add a scope attachment(which it has) it should be ok to use if I dont add any other attachment tags in the xml? Working on a weapons modlet, and currently just using ingame models with different tints. Would be nice if I could add custom models and sounds to them aswell :)

Link to comment
Share on other sites

I assumed people had gone through Xyth's basic unity tutorials because he's done WAY more than me. ;)

 

Piece of leather like that means the XML is somehow wrong. That's what 7DTD does when it can't find the model for whatever reason (For the record, I've literally had that happen, changed the name of the .prefab file in unity, re-exported and then it's worked for no reason).

 

I believe other tags are not REQUIRED, but may throw NRE's if you try to attach a mod that doesn't have the appropriate "slot" defined on the prefab for the transform.

Link to comment
Share on other sites

Hehe, I would assume most people watching it, at least those with the intent of doing anything with it, have watched his videos. And I will do so later or tomorrow. Its just that you made it look quite easy using a free asset and just importing it so I thought I'd have a go at it :)

I did make it twice, after first failed, to make sure I hadn't missed anything. And used a slightly different name, incase the underscore in the first could be one reason. I'll try and export the same one with different name later when I get home.

 

As long as other guns work without the other tags it shouldn't be an issue. Can just remove the attachment tags from the xml. And try adding the ones that's appropriate for the different weapons when I get the basic models working.

Link to comment
Share on other sites

You were indeed right, renaming the prefab an re-exported it and it worked like a charm :) I did have to add -270 degrees for the attachments for side and scope to point the right direction (and I realised now that I could just used 90 without the minus...). Side also needed to move ca 0.6 further back. Plus the barrel same rotation adjust but position x2.5 y0.2 ca to not be same place as the scope :) ( I did add the gun to the item_modifiers list first to see if that corrected enough, which it didnt). But I got a working gun thx to your tutorial after never used Unity editor before, so thx again for a very nice and easy to follow tutorial :) There might be a few new guns in the mod section soon ;)

Link to comment
Share on other sites

  • 2 weeks later...

I've been following the tutorials and have managed to do the flag and the gun like you have in the video and make it work in the game. I used to play with Unity a lot when my son was in college for game design and we spent a good part of a year trying to make our own game. Meaning I still have a lot of bought assets laying around that I can use. I was trying to make a new trap but cannot get it to work. I was trying to use the spinning blade trap as a template but I am unsure of what tag I should use for one and animation on my prefab is the other. My hammer trap has a spinning animation attached. How could I get that in the game to work with electricity like the spinning blade trap? So far I keep getting NRE on every attempt so I figure it has to be something with the tags and perhaps the electrical stuff is more complicated? I also notice that the traps all use LOD, does that make a difference? If I am using the xml blade traps as a template for my hammer trap is it looking for all those LOD models?

Link to comment
Share on other sites

  • 2 weeks later...
Very useful video.

 

Could you make a guide on how to add armor?

 

We can't add new UMA models yet.

 

It sucks. -_-

 

- - - Updated - - -

 

I've been following the tutorials and have managed to do the flag and the gun like you have in the video and make it work in the game. I used to play with Unity a lot when my son was in college for game design and we spent a good part of a year trying to make our own game. Meaning I still have a lot of bought assets laying around that I can use. I was trying to make a new trap but cannot get it to work. I was trying to use the spinning blade trap as a template but I am unsure of what tag I should use for one and animation on my prefab is the other. My hammer trap has a spinning animation attached. How could I get that in the game to work with electricity like the spinning blade trap? So far I keep getting NRE on every attempt so I figure it has to be something with the tags and perhaps the electrical stuff is more complicated? I also notice that the traps all use LOD, does that make a difference? If I am using the xml blade traps as a template for my hammer trap is it looking for all those LOD models?

 

I -think- blocks that use electricity need very specific tags in order to work, but I have not messed with that to be totally honest with you.

Link to comment
Share on other sites

  • 2 weeks later...

Hello KhaineGB, awesome video you did, i wanted to thank you for it, thanks to it i created the Soviet Pack, really thanks!

And one question, im trying to implement a Animation to a gun, in Unity everything is working fine, im using the Animator to do it, but when i put the gun in game the animations don't work,do you have any idea why this is happening?

Link to comment
Share on other sites

I'm still working out animations myself. Took me 3 days to do 1 crossbow.

 

The main ones you need are an empty idle anim, a fire and a reload. I find that using triggers work's better than bools and you MUST have your animator on the empty parent object within unity, NOT on the model.

Link to comment
Share on other sites

  • 11 months later...

I cannot seem to locate pistolPrefab (or any of the other gun prefabs) inside of resources.assets. First I tried filtering by the term 'pistol' inside of asset studio and I saw a bunch of animation clips and sound files, but no prefab or mesh. I exported all of resources.assets and still couldn't find a pistolPrefab inside. Is there something I am missing? I'd really like to get working on getting some new guns imported and this is quite baffling, it's as if that file just doesn't exist.

Link to comment
Share on other sites

^ that.

 

All weapons seem to be in that file now. :)

 

Khaine, any idea how the animation controller would look for bows? I know it needs a hold, draw, draw idle, fire, fire cancel, and reload animations. I'm pretty sure I know the transitions, but I'm not certain how to trigger each animation within the items.xml file.

Link to comment
Share on other sites

  • 1 month later...

Export script still works. :)

 

I think I'm using 2018.something for unity. If you open your log file, it tells you what version of unity the game is using.

 

That's the one I currently use. I think Xyth is using 2019.2 for his entities though.

Link to comment
Share on other sites

As suggested i'm using unity 2019.1.14, but I am getting the following error (Null Reference Exception: Object reference not set to an instance of an object) when loading up. Untitled.jpg.faeb2e87cdcfc79fe1e6186aa21142ed.jpg

 

 

 

 

 

Here's my hierarchy in Unity, followed the same pattern as the 7d2d A18 pistol

Capture.PNG.8c14fae9c39aa25c7d935cb53757a820.PNG

 

And the XML file, used pistol as a base

 

Capture2.PNG.213be2788c19db47c3361a3704ec87df.PNG

 

Help would be appreciated. Thanks !

Link to comment
Share on other sites

  • 1 month later...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...