Hello everyone,
i am christopher and I come from germany.
So i apologize in advance for my bad english^^
I have get the asset “Ultimate Survival” and so on, I have see some tutorials about this asset
and integrate something from this tutorials into my project.
So on, so good. The tutorials are from the “messy Coder” - guy which has fantastic detailed
examples.
But now, I implement this example in this video:
I have everything done in this video but I get a nullpointer.
When I use this code, the method GetComponentInParent return null
in the class “AmmoDragHandler” in row 32.
itemDragHandler = transform.GetComponentInParent<ItemDragHandler>();
And I get a NullPointer in the class “ItemDragHandler” at row number 147
if (ammoDragHandler.LoadAmmo(initialSlot, itemUnderPointer, m_DraggedItem)) {
return;
}
What can I do to solve this problem?`
kind regads,
Christopher T.
For the first one, there is no ItemDragHandler found… you have to make sure it’s there on the object or parent.
Same thing with the next one, in that if it’s null, it wasn’t found/assigned properly. Can’t tell from the code you provided, but if you fetched the reference to ammoDragHandler at some point earlier, it may have come back null. If it’s possible that it can come back null, you have to guard against calling it when it does. If it should never be possible to come back as such, then you should make sure that it’s added properly to any game object, as well as referenced correctly.
1 Like
Hi,
I have seen that I have one Option which is set differently, when I select a weapon in the Inspector, as the guy in the video has.
There is an option called “ammoDragHandler”, which is not set, but in the Video at 33:00
You can see that this is set with “InventoryController”.
But when I try to set the InventoryController, unity say that it can’t add this.
What could it be? I checked the class extension of the class AmmoDragHandler and the in the ItemDragHandler
which are MonoBehavier.
So I think that was right, cause the guy in the video has it too.
Someone else and I ran into problems when (I think) assigning transforms / GameObjects in the inspector. Check this tread out for more info.
Jemand anderes und ich lief in Probleme, wenn (ich glaube) Zuweisungen Transformationen / Game Objects im Inspektor. Überprüfen Sie diese Lauffläche für weitere Informationen.
The code that I posted in the other link above worked to get me around the problem. But hopefully unity will provide a fix for it soon.
I solved it yes =)
But I think this was a little bit stupid issue for myself.
I had to switch the AmmoDragHandler skript into the Inspector while the InventoryController is selected.
I didn’t see it in the video, but so on, the skript could reference the ammoDragHandler-object from the function.
I Hope my answer are readable 
If you don’t understand what I try to tell you, I can write it in a different formulation.
I’m glad that you got it fixed 
Thank’s =)
I know this is not the right place to write it down but,
may you know some tutorial to import a new NPC to the game?
I did the tutorial from the guy at the video above, but in this video
he show, how can I add an NPC wich is likely the same as one other NPC which already exists.
The only difference between each other is, that the new NPC has another Model 
For example I want to add this Monster to the game Unity Asset Store - The Best Assets for Game Making
I tried it like the NPC in the video, but I can’t add a ragdoll over the gui-wizard from Ultimate-Survival-Tool
Maybe make a new thread describing what you’re looking for, for some good feedback (since it’s an entirely new subject). 