- Home /
Question by
Babilinski · Nov 24, 2011 at 05:49 PM ·
c#collisiontriggerlist
Creating a list with trigger
How can I use
void OnCollisionEnter(Collision collision){
if (collision.gameObject.tag == "Enemy"){ //stuff } }
to create a list of transforms ?
Comment
Best Answer
Answer by cj_coimbra · Nov 24, 2011 at 07:30 PM
I am not sure if this is what you want...
private List<Transform> transforms = new List<Transform>();
void OnCollisionEnter(Collision collision)
{
if (collision.gameObject.tag == "Enemy")
{
//stuff
transforms.Add(collision.gameObject.transform);
}
}
Your answer
Follow this Question
Related Questions
On Trigger Enter, Collide with object, specific collision 1 Answer
Animation with frozen player ?? 0 Answers
Why the npc character walking strange when using a Rigidbody and Is Kinematic on enabled ? 1 Answer
How to enter trigger a certain amount of times before executing code? 1 Answer
Open door = load scene c# issues 4 Answers