Multiple collison polys?
by Dan Pascal · in Torque X 2D · 10/25/2007 (10:28 am) · 4 replies
Hi,
I want to shoot at a barrel and watch it burn and explode the more it gets hit.
I'll create a component for hit points and different damage levels and all that and add it to the barrel sprite.
I'm already using the barrel sprite's collison poly for player collision, and that poly is a narrow oval just around the base of the object.
So, if I create another blank scene object and use it's collision poly for bullet collisons,
how do I associate that it with the barrel, (which has the hit point component)? mounting maybe; but what would that look like in code?
Or any examples somewhere?
Thanks
I want to shoot at a barrel and watch it burn and explode the more it gets hit.
I'll create a component for hit points and different damage levels and all that and add it to the barrel sprite.
I'm already using the barrel sprite's collison poly for player collision, and that poly is a narrow oval just around the base of the object.
So, if I create another blank scene object and use it's collision poly for bullet collisons,
how do I associate that it with the barrel, (which has the hit point component)? mounting maybe; but what would that look like in code?
Or any examples somewhere?
Thanks
About the author
#3
It seems "myObject" references the blank scene object and not the sprite; even though the component was added to the sprite. So even though the hitComponent registers the impact, it doesn't give me the reference on the sprite.
another way?
10/25/2007 (11:26 pm)
John, It seems "myObject" references the blank scene object and not the sprite; even though the component was added to the sprite. So even though the hitComponent registers the impact, it doesn't give me the reference on the sprite.
another way?
#4
if I use the sprite's poly for bullet collison , and use the blank scene object poly as the player collsion poly, (it was the other way around before)
that fixes all that
thanks
10/26/2007 (6:36 am)
Ahhif I use the sprite's poly for bullet collison , and use the blank scene object poly as the player collsion poly, (it was the other way around before)
that fixes all that
thanks
Associate John Kanalakis
EnvyGames
Suppose you have a component called HitComponent. Add something like this:
public static void ApplyDamageFromSceneObject( T2DSceneObject myObject, T2DSceneObject otherObject, T2DCollisionInfo info, ref T2DResolveCollisionDelegate resolve, ref T2DCollisionMaterial physicsMaterial) { //perform damage processing } [TorqueXmlSchemaType] public static T2DOnCollisionDelegate BulletHit { get { return ApplyDamageFromSceneObject; } }The ApplyDamageFromSceneObject() method will change the hit points for the component. The BulletHit delegate exposes this delegate to other code.
Then, you can go into Torque X Builder, add the hit component to your barrel, then add a blank scene object. Add a T2DCollisionComponent to the blank scene object, identify the object tpe it collides with, and then click the OnCollision list box and choose the BulletHit delegate. Your hit component should register the impact, even though the collision came from the blank scene object. That should do it.
John K.