(newb) Can some one help me understand why this script is not working?

The referenced script on this Behaviour (Game Object ‘Player’) is missing!
it also says the associated script cannot be loaded please fix any compiler errors and assign a valid script.
is the error i’m getting, what is this telling me? here is my script…

using UnityEngine;
using System.Collections;

public class PlayerMovenet : MonoBehaviour
{
    public float thrust;
    public Rigidbody rb;

    void Start()
    {
        thrust = 10;
    }

    void FixedUpdate()
    {
        if (Input.GetButtonDown("w"))
        {
            rb.AddForce(transform.forward * thrust);
        }
    }
}

I’m simply trying to learn how to apply a force to an object to make it move forward, pretty simple stuff. -.-

my object has a rigidbody it has a box collider

Hmm could you upload the scene?

https://www.dropbox.com/s/2t733mem349k64v/Test.unity?dl=0

i hope just the scene will do. thanks for the reply!

First off, I think that the GetButton family, including GetButtonDown works with the named axes in Project Settings → Input (Fire1, for example, as seen in documentation). I am not sure, though, have never used it.

Second, and most important(!) is the fact that the Input methods ending with Down (MouseButtonDown, KeyDown, ButtonDown), are a little bit misleading, yes - but they are fired ONCE, the first time (frame, technically) the event is triggered. So, in your case, it’d fire for the first frame only but not while holding it down.

What you are looking for, is GetKey: Unity - Scripting API: Input.GetKey, or any equivalent that does not end with Up or Down.

Also… Input is updated once per render frame not physics frame, therefore it should be put in Update not FixedUpdate. It will work nonetheless, but it won’t fire quicker/more precise, as it is locked to the render frames.

Even after changing it to “if (Input.GetKey(“w”))” nothing is happening i even threw in Debug.Log(“test”); and its not printing anything, it’s as if the script is just not running at all.

Have you added the script to a GameObject?
Have you assigned a Rigidbody to the script?
Are there no errors in console?

Script attached to game object - Check
Assigned RigidBody to script - ? not sure i follow
Any errors in console - The referenced script on this Behaviour (Game Object ‘Player’) is missing! and
The referenced script on this Behaviour is missing!

Your script has a public field rb of type Rigidbody. The field requires that you provide an object to it, otherwise there will be a missing reference. When you add your script to a GameObject, the Inspector view will show all the public fields (not always, but for most part… serialization is the key here - don’t dwell too deep into it now) and allow you to assign values to them.
In this case, the GameObject to which you assigned the script, also requires that you assign a Rigidbody object to the script.

This one is interesting, as it is telling that there are some missing references. Check your Player GameObject and see if there aren’t any warnings and/or errors and/or suspicious scripts.

Given that your script is PlayerMovenet (is the typo intentional?) I assume that the GameObject named Player is the one that has the PlayerMovenet script attached. Though, it could have lost reference to it, given the warning in console.

Have you maybe moved/renamed the script after initial creation? That could make Unity forget the references. Though, make sure that the GameObject you assigned your PlayerMovenet script to is actually correct and still has the reference. If it is there, the script should be working.

How would i add an object to it? i assumed it would identify the player object since it’s in the player object script. could you show me an example of the code that would work?

The code should be working as it is now. You might have some reference problems over on your side.

Double click this error, it might take you to the erroneous place (not sure, though). In other words, fix this error up.
Maybe post a screenshot of your Hierarchy window and Inspector window once Player GameObject is selected.

Okay i got it all working now, thanks for every ones help!

What was the problem?

[quote=“tomsseisums, post:12, topic: 626382, username:tomsseisums”]
What was the problem?
[/quote] once it was pointed out that PlayerMovenet was spelled wrong, i realised how big of an idiot i was and from there i was able to attach the rigid body to the script from the player object