- Home /
how can i make a List of rigidbody
i need to make a list of rigidbody, but i can't to add new rigidbody from ontriggerenter, how can i fix this,,,
public List<Rigidbody> rb;
void OnTriggerEnter(Collider other)
{
rb.Add ( new Rigidbody (other.GetComponent<Rigidbody>()));
}
Comment
Best Answer
Answer by NorthStar79 · Nov 20, 2017 at 07:13 AM
try this :
public List<Rigidbody> rb = new List<Rigidbody>();
void OnTriggerEnter(Collider other)
{
rb.Add (other.gameObject.GetComponent<Rigidbody>());
}
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
A node in a childnode? 1 Answer
Distribute terrain in zones 3 Answers
C# List For Loop Only Returns Last Element 0 Answers
Flip over an object (smooth transition) 3 Answers