Unity Code Error question


I am doing an exercise on youtube for a quick and simple game. (https://www.youtube.com/watch?v=qwuPiaFU37w)

I followed the video instructions and wrote the same code, but I get error messages and can’t get it to work, although it’s working in the video.

Please see error messages attached

I am not sure I understand these error messages (I’m a beginner in Unity). Can I fix this somehow ?

Also, I might not be using the same Unity version as the person in the video. Could this be the reason it’s working on his and not mine ?

I’m using Unity version 5.4.2f2.

And one last question: do I generally need to make sure I have the same Unity version as the person doing a tutorial or is that not so much of an issue ?

Thanks :slight_smile:

Hello Alex,

Put gameObject. before the GetComponent


The error message is saying that the Component doean’t have anything called velocity or AddForce to reference, this would be because it hasn’t found the Rigidbody component on the GameObject your script is attached to because of the missing gameObject. prior to the GetComponenet statement.

You dont necessarily need to have the same version as the tutorials but if you dont you will need to factor in some time to research differences between them so that you can understand what is going wrong when it goes wrong.

In the above example running off to the Unity documentation website for the GetComponent method was all that was required.

It would serve you well to consider taking the Complete Unity Developer course for which this community exists.

Hope this helps. :slight_smile:

Thanks :slight_smile:

1 Like

You are more than welcome Alex. Let us know if you have any other queries and we will see if we can help :slight_smile:

Privacy & Terms