0

I've been trying to learn Unity and pretty soon in the tutorials I've found this:

private Rigidbody rb;

void Start ()
{
    rb = GetComponent<Rigidbody>();
}

I'm not knowledgeable with C# syntax so what I really would like to understand is this function<object>() syntax.

Thx

1 Answers1

1

This is generics.

https://msdn.microsoft.com/en-us/library/0zk36dx2.aspx

Essentially you're telling the Unity runtime to give you the RigidBody component. It's similar to doing something like

rb = GetComponent(typeof(RigidBody));

mariocatch
  • 8,305
  • 8
  • 50
  • 71