public float jumpPower = 10.00f;
public bool isGrounded = false;
Rigidbody2D myRigidbody;
// Use this for initialization
void Start()
{
myRigidbody = transform.GetComponent();
}
I’m no moderator, but it makes it easier to get answer if:
EDIT:
And in general, you are not paying anyone for some service, saying just “help, not working” and printing code on screen might not be the best approach to get help
I didn’t say he couldn’t do it.
I am saying his log will very likely say that the rigidbody is null because attaching a rigidbody to a transform is weird.
No, it’s really not. I don’t think you understand what GetComponent does. It looks for another component on the same GameObject as the component you’re calling it on.
If your GameObject has a Rigidbody, then transform.GetComponent is not null. In fact transform.GetComponent() == GetComponent() == gameObject.GetComponent == someOtherComponent.GetComponent(). They are all the same thing.
I don’t know what the OP’s actual problem is, but this isn’t it.