Sword equipped in the wrong place

Hi everyone! I’ve been making a RPG game for a school project. Note that I don’t know anything about Unity and C# so I’ve been following a tutorial (you can find it here: https://youtube.com/playlist?list=PLPV2KyIb3jR4KLGCCAciWQ5qHudKtYeP7&si=WNx-UA_5qHikPEbJ). The armour equips just fine. My problem is that, when I equip the weapon, It’s being place in the spine of the character. I’ve been searching for days and I can’t find anything :frowning: I will attach the script and some photos to show you what I mean.

9641606–1370933–Equipment.cs (720 Bytes)
9641606--1370942--armorequipped.png
9641606--1370945--swordgoinginspine.png

I would review where the tutorial tells you to attach it as well as review any offset you might have on the weapon.

Unity is great this way because you can press PLAY, then PAUSE, then go digging into your scene and find the sword, find what it is attached to, move it to what it SHOULD be attached to, then reason about what code made it go to the wrong place and fix that.

Remember: tutorials have two steps only:

  • do them perfectly, without fail
  • stop and understand every single part well enough to explain it to your dog (see my avatar)

Hi, yes, but I can’t do that because when the item goes into my inventory and I equip, it disappears from the hierarchy :frowning:

No game object disappears from the hierarchy, unless you destroy it. If you can see the game object on the screen, it is in the hierarchy, you just need to find it. Your sword is probably a child of the character (or one of its bones game objects, so it can be really deep in the hierarchy).

Tip: A simple Debug.Log("Sword equipped", swordGameObject) will highlight the game object in the hierarchy when the log entry is clicked, making it very easy to find.

1 Like

When I pick it up from the ground it get’s destroyed yes. It goes into my inventory.

You said “when I equip the weapon, It’s being place in the spine of the character”.

So you do have a sword game object, probably a clone of the original one you destroyed when your character picks it up, but still a sword game object.

I see, thank you :slight_smile:

UPDATE: I FIXED IT!! Thanks to everyone who replied :slight_smile: