Game Development Community

PowerUpComponent problem

by Jester Carvalho · in Torque X 2D · 03/03/2011 (8:43 am) · 0 replies

I have a slight issue. If I create a power up to change rate of fire it works properly if put directly on the scene, but if I change it to a template to be spawned at random through a destruction effect it does not inherit the components of the parent(nothing happens). I am also wanting to give each power up a time limit but not sure how to code that in. Any help would be appreciated. I am currently working in TorqueX 2D CEV4.0 and VS2010. I think It has to do with this part of my code but not sure at this point.

public override void CopyTo(TorqueComponent obj)
        {
            base.CopyTo(obj);
            PowerUpComponent obj2 = (PowerUpComponent)obj;
            obj2.Name = Name;
        }



        public static void PowerUpCollision(T2DSceneObject ourObject, T2DSceneObject theirObject, T2DCollisionInfo info, ref T2DResolveCollisionDelegate resolve, ref T2DCollisionMaterial physicsMaterial)
        {
            for (int i = FireProjectileComponent._activeProjectiles.Count - 1; i >= 0; --i)
            {
                FireProjectileComponent._activeProjectiles.RemoveAt(i);
            }

            // Get a target objectType   
            if(ourObject.Name == "PowerUp2")
            {
                FireProjectileComponent._projectileType = FireProjectileComponent._fireProjectile;
               
            }
            if (ourObject.Name == "RapidPower")
            {
                FireProjectileComponent._projectileType = FireProjectileComponent._rapidProjectile;

            }

            
        }

        #endregion