Reputation: 765
I have components in my player object like:
How can I acces in PlayerMovement.cs that RigidBody? How can I find it?
Thanks!
Upvotes: 0
Views: 85
Reputation: 309
Create a Rigidbody object like
Rigidbody object;
and use
object = GetComponent<Rigidbody>();
in Start()
method. This works for Unity 5
Upvotes: 1
Reputation: 692
Main thing is to create a reference variable of type RigidBody like below.
RigidBody rb;
Then you can access the game component by using GetComponant<RigidBody>;
function.
So now you can access to the rgid body componant as like rb.mass = 300;
hope this will be helpfull to you.
Upvotes: 1