i wanna ask, in my video tutorial, it’s used rigidbody but when i try to use it, it says the following error msg:
what am i supposed to use and do?
i wanna ask, in my video tutorial, it’s used rigidbody but when i try to use it, it says the following error msg:
what am i supposed to use and do?
yes, it is. use GetComponent() instead, literally what it says
In eariler versions of Unity, Monobehaviour had a property called “rigidbody”. later, in a desire to make scripts more decoupled, they depreciated the property (not every monobehaviour needs a rigidbody) so the variable still exists, but should not be used.
In your scripts don’t call your variable “rigidbody” but something like “rb” since rigidbody already exists in the parent class and was depreciated.
Please stay away from tutorials that are two years old in the future. It might not be much, but in two years a bunch of updates happened (I’m not sure, but the new UI system might be less than 2 years old)
@gorbit: can you suggest several decent tutorials? (either ebooks or videos)
Go to the learn section of this page, there are the official tutorials
@gorbit: is there’s anything else?
There are a lot of good tutorials, just google them, but if you want something, that will surely work, you need to do those
it would be hard to recommend anything without knowing your current experience level and what you want to accomplish.
if new a good starting point is Learn otherwise i heard this youtube channel is rather good. https://www.youtube.com/user/Cercopithecan
ok, thx bro
rigidbody was a shortcut they removed.
So just replace it with GetComponent() as mentioned, but you should cache it at the top.
public class Whatever : MonoBehaviour {
private Rigidbody rb;
void Awake()
{
rb = GetComponent<Rigidbody>();
}
void Function()
{
rb.AddForce //......etc
}
}
@Stardog : roger that