Game Development Community

Collision COmponent...CollidesWith

by DINF CLL · in Torque X 2D · 11/12/2007 (5:42 pm) · 2 replies

I am trying to modify de Blaster tutoriel to make new kind of enemi. So I need my projectile to collide with to kind of ennemi.

I read that we can combined TorqueObjectTypes to form a collection of object types with which to collide.

How can I construct that kind of collection...

I search the doc and the forum...nothing on that... I try a few thing like:

projectileObj.Collision.CollidesWith = TorqueObjectDatabase.Instance.GetObjectType("Ennemy1") + TorqueObjectDatabase.Instance.GetObjectType("Ennemy2");


Some one can help me

#1
11/12/2007 (5:55 pm)
I find this to be much easier to do in Torque X Builder. Make sure nothing is selected, then go to the Edit tab and expand the Scene Data rollout. Create the object types you want by typing an Object Type name and clicking the green Add button. Next, select your component that will be doing the colliding. Expand the Components rollout and then, select the properties for the T2DCollisionComponent. In the CollidesWith drop down, select the object types you want to collide with and the click the green Add button. Finally, associate the different object types with each scene object. Select a scene object, expand the Scripting rollout, then choose an Object Type to associate and click the green Add button.

That should do it. You can do all the same steps in code, but it will take a little longer to type up.

John K.
#2
11/15/2007 (9:04 am)
I already try this solution, but it cum up with 2 problem:

1- My enemy can kill each other end I do not want that.

2- When a enemy is firing it is killing himself in fact. Why, because the starting point opf the projectile is the same then then enemy position that is firing. So it collide immediatly with the projectile and killing itself. Setting up the projectile starting point a litle bit in front of the enemy will solve the problem... but not the first problem.


So this is why I have to set up the CollidesWith in the code not in TXB...


Thank's