Linking prefabs to (another) game object

i’m learning game making in here:

but looks like my unity (5.6) with what used in that video is a bit different.

in that video (i don’t know if i missed something), the prefabs just drag and dropped in the player’s field.

in my unity, i should assign the script for gun and then i still can’t drag and drop the prefabs
i should click on a circle button near the variable’s field to display the prefabs (gun) and select it

can anyone explain it why?

name the script same as the field

-EXACTLY- the same

I would suggest not naming your things different from the tutorial unless you understand what you’re doing. :slight_smile:

Also, what is the logic behind your naming convention? If there isn’t one you should start using one where there is immediately in my opinion. Looking at the 4 scripts in your screenshot: “GunCtrller”, “GunStuff”, “ThePlayer” and “ThePlayer_Ctrl” tells me nothing about how I would name a 5th script in your project and I think that’s extremely bad. It would obviously be next to impossible for you to make a game working with another person, but just for your own sake when your projects start increasing in scope and complexity this will lead to a lot of frustration, guesswork and time wasted trying to remember what you named things.

I don’t know if this problem is related to the above, but you’ll have a lot of similar problems going forward if you continue naming your scripts, and presumably your variables, classes, methods etc., in this fashion.

My suggestion is to to just be wordy and always write things out in full. I personally don’t care how long a class or variable name becomes if that’s what it takes for me to easily understand what it does or what it’s for years later. But above all be consistent.

3 Likes

i name it that way bcoz it’s just a test project.

i, too, would consider the bad naming in serious projects.

i’ll try and i’ll tell you the result later

Your prefab needs to have the’ GunStuff’ component on it.

1 Like

do you mean the script or the variable?

btw, why after i assigned all the gun scripts (gunstuff and gunctrller) and assign the prefabs to the player from here:

when i press the play button, the gun pointing to the opposite direction of my mouse?

It’s probably bcoz it’s just a test project.

1 Like

be serious, bro