- Home /
Can't access rigidbody commands 'Rigidbody' does not contain a definition for...
I am trying to write this: public void Speedboost(Rigidbody m_Rigidbody) { Vector3 OriginalSpeed = m_Rigidbody.velocity; } I want to access the velocity of the Rigidbody, but it triggers an error that says: 'Rigidbody' does not contain a definition for 'velocity' I can be certain that this command exist, so why isn't this working? I would appreciate any help, thanks in advance! Here's an official unity link to that exact command: https://docs.unity3d.com/ScriptReference/Rigidbody-velocity.html
Answer by NorthStar79 · Jul 31, 2017 at 10:58 AM
try this :
m_Rigidbody.GetComponent<Rigidbody>().velocity;
I resolved the issue, it appears that Rigidbody had it's own class so I had to use this:
Answer by Yoshinator2 · Jul 31, 2017 at 03:28 AM
You have to get the component first
m_Rigidbody = GetComponent();
Your answer
Follow this Question
Related Questions
Can't access the velocity of a rigidbody: 'Rigidbody' does not contain a definition for 'velocity' 1 Answer
Velocity powered rigidbody on a moving platform without parenting. 3 Answers
Space Shooter tutorial shot velocity issues 0 Answers
When I try to save the velocity of a rigidbody and use it later it doesn't work? 1 Answer