- Home /
Can't access the velocity of a rigidbody: 'Rigidbody' does not contain a definition for 'velocity'
From what I understand you can access the speed value of a rigidbody by typing: rigidbody.velocity for some reason it gives me the error: 'Rigidbody' does not contain a definition for 'velocity' (attached). What am I doing wrong? I also attached the entire script in case there could be a definition problem.
SpeedBoost is passed a Rigidbody, why do you assign it a value? You should get rid of line 29.
First, why are you getting a Rigidbody component from a Rigidbody?
m_Rigidbody = GetCompoent<Rigidbody>();
Answer by Bunny83 · Aug 03, 2017 at 05:27 PM
Given the error you most likely named one of your own classes "Rigidbody". That class hides Unity's "UnityEngine.Rigidbody" class. You should generally avoid using any names of built-in classes for your own.
So the best solution is to rename your Rigidbody class into something else. If you want to keep that name you have to use the "fully qualified type name" UnityEngine.Rigidbody
every time you want to refer to Unity's Rigidbody class.
Your answer
Follow this Question
Related Questions
Can't access rigidbody commands 'Rigidbody' does not contain a definition for... 2 Answers
Problems with velocity in Unity 5 3 Answers
How to set velocity to a previouse value 1 Answer
Changing 1 parameter of rigidbody.velocity (Vector3) 2 Answers
Do rigidbodies (especially 2d) have limits on their velocities? 1 Answer