Why does rigidbody.velocity not work like it does in the tutorial?

In the space shooter tutorial the rigidbody.velocity code doesn’t work for me. I tried capitalizing, like Rigidbody.velocity and Rigidbody.Velodity, but nothing worked. Why is that?

Hi :slight_smile: I think you need to add this line of code.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
 
public class Jump : MonoBehaviour {
 
    /// <summary>
    /// You need to attach Rigidbody 2D component to your Player
    /// </summary>
    private Rigidbody2D rb;
 
    void Start ()
    {
    /// <summary>
    ///  Script need a reference to Rigidbody 2D component
    /// </summary>
        rb = GetComponent<Rigidbody2D>();
    }

Where should I put this code?

Note: I also looked on the internet and found that I needed to use GetComponent() and it seemed to work fine.