Get Rigidbody contacts
I'm puzzled at the function one must use to retrieve the contacts points from a rigidbody2D : public int GetContacts(ContactPoint2D[] contacts);
Why isn't it simply public ContactPoint2D[] GetContacts();
? How do I even use it properly?
Answer by gouafhg · Mar 03, 2018 at 10:51 AM
It's there to reduce memory allocation and overhead. With your proposed method, there would have to be some kind of allocation within which would have to be run every time you call it. This would probably make the memory garbage collector work pretty hard.
However, with the current method, you allocate the memory for yourself. This gives you the control over how much and how often you want to allocate memory for the array.
Your answer
Follow this Question
Related Questions
HELP! RigidBody2D position is acting incredibly goofy!! 0 Answers
How to simulate damage due to friction 0 Answers
[HELP] 2D Ammo UI error wont count down shooting count and wont pick up and change ammo count 0 Answers
How Calculation a new rotate on circle2d when add torque 0 Answers
Projectile Changing Angle BEFORE Impact 0 Answers