Moving a simple Object across the Screen Issue

Hello Unity Community,

I been having a hellish time trying to move a simple square sprite across a solid color BG. I have followed and watched a ton of step-by-step Unity Tutorials in how to script a moving object across the screen and yet I’m getting errors that they don’t receive.

The error the I get is when I type in rigidbody2d.velocity. When I hover over the red underlined velocity in the code it tells me, “‘UnityEngine.Component’ does not contain a definition for ‘velocity’ and no extension method velocity accepting a first argument of type ‘UnityEngine.Component’ could be found (are you missing a using directive or an assembly reference?)”.

I have absolutely no idea what it is trying to tell me. Can anyone tell me how to solve this annoying issue? See the attachment to view my script for this problem.

The problem is that most of the tutorials are for Unity 4 and things are a bit different in Unity 5 so rigidbody2D.velocity is obsolete.

This should do it:

Vector2 example = GetComponent<Rigidbody2D>().velocity;
example = new Vector2(moveSpeed * move, example.y);

Component.rigidbody2D