Scripting Help

Okay this is my problem, I’m a semi-noob at Unity and I’ve come across a problem when I’m scripting. It’s kind of hard to explain.

I watch tutorials on Unity for example how to make player float, adding footstep sounds and so on. But I have a problem with any script type I make…

For example, when I drag a floating script into my FPS player, I don’t get the options that all people do like changing the force with a little slider button under the component. And today, I took a script from this forum which was how to add footstep noises every time I move (walk) and the guy said once you drag the script into the player. You can then have the option to add in an audio file… but there’s no spot for that kind of thing.

Like in this picture, under script, I never ever get the options 16947-capture.jpg

I always get this kind of thing, without any extra options16948-captaure.jpg

So what I’m asking is, how do people get options with their script under the components tab because I’m copying the scripts exactly and nothing works for me…

If anyone can answer this for me, they’re fantastic because I can defiantly enhance my game if I know what the problem is. Cheers.
P.S apologies for the small image

Make sure your variables access specifiers are public.

in C#, you have to explicitly use the public keyword when you declare a variable:

public float f;

If you declare it without an access specifier, it’s then private by default (as if you put private in front of it):

float f; // same as private float f;

In JS however, it’s the opposite, if you don’t specify an access specifier, it’s public by default, and if you wanted it to be private, you have to explicitly tell it to:

var f : float; // same as public var f : float;

A variable is only visible in the inspector if it was public, so make sure the stuff you need isn’t private

private means that other classes can’t access your current class variable.

What if, you wanted a private variable, other classes can’t have access to, but yet let it be visible in the inspector?

you add the SerializeField attribute before your variable declaration, like:

[SerializeField] private float f; // C#

and

@SerializeField
private var f : float; // JS