Whats wrong in this code , its done thanks

whats wrong in this code , he is saying velocity is the problem
please help me,
using UnityEngine;

public class movment : MonoBehaviour
{

public Rigidbody2D body;




// Start is called once before the first execution of Update after the MonoBehaviour is created
void Awake()
{
    body = GetComponent<Rigidbody2D>();
}

// Update is called once per frame
void Update()
{
    body.Velocity = new Vector3(0, 0, 0); 
}

}

Check the docs: Unity - Scripting API: Rigidbody.velocity

Capitalisation matters.

1 Like

When asking a question, you should always provide as much information as possible, such as what you’re trying to achieve, what you’ve attempted so far, what’s happening, what you expected to happen, and the Unity version you’re using.

I’ll take a guess and assume you’re following a tutorial for an older version of Unity while using Unity 6. In Unity 6, Rigidbody2D doesn’t have a velocity property; instead, it uses linearVelocity.

If you’re working with an older Unity version, then this might simply be a capitalization issue, as @spiney199 pointed out.

EDIT: Actually velocity still works, it is just marked as obsolete, so it is just the capitalization. You should still use linearVelocity though

1 Like

you are right thank you

thank you so much