Why do we need the GetComponent at all at 4:13? We already have the projectile as a Rigidbody through the public variable.

Forum Archive Why do we need the GetComponent at all at 4:13? We already have the projectile as a Rigidbody through the public variable.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #4755
    Chris Johnson
    Participant

      Why do we need the GetComponent at all at 4:13? We already have the projectile as a Rigidbody through the public variable.

      #23013
      Jonathan Gonzalez
      Participant

        Yes I see what you’re talking about, it was unnecessary since we don’t need to access anything within the component itself. Not sure why I added it actually as I never do that with projectiles. Thanks for pointing it out.

        #23014
        Jason Finney
        Participant

          But I thought it was necessary since the script was being added to the GameObject(empty) so in order to use the RigidBody of another GameObject(sphere prefab) didn’t it need the GetComponent to make a reference to the RigidBody component so we can edit the velocity?

        Viewing 3 posts - 1 through 3 (of 3 total)
        • The topic ‘Why do we need the GetComponent at all at 4:13? We already have the projectile as a Rigidbody through the public variable.’ is closed to new replies.