Announcement

Collapse
No announcement yet.

Destroy child actor

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Destroy child actor

    Hi

    I am creating a small game in which you can shoot different projectiles with different effect as fire, electricity ...

    I created a Actor Class called "BP_Effect" which contain a particule system and a small script. When I touch a monster which a projectile, the monster will get the effect. (For exemple, the monster is hit by a fire projectile, the monster will be on fire).

    In my "BP_Effect", i have a timer. When the timer is over, I destroy the effect (child actor). The fact is that it work, but not too much ...

    The particle system and script are destroyed, but the monster still has an BP_Effect class child component...

    I tried to use the function "destroy component" , but it does'tn work...

    Here some screenshot, in the evening i will try to make a short video to show the problem.

    HELP

    #2
    Try adding a function in your monster class that gets the child actor component and calls the Destroy Component function (just in case the destroy component you mentioned was called on the root component of the effect blueprint) on it.
    Last edited by Stormrage256; 10-21-2019, 10:08 AM.
    Tower Defense Starter Kit | Grid Creation Systems | Top Down Stealth Toolkit

    Comment


      #3
      Her a video which explain my problem :https://www.youtube.com/watch?v=mhEjesaZc-Y

      Sorry for my French accent

      Comment


        #4
        Originally posted by Stormrage256 View Post
        Try adding a function in your monster class that gets the child actor component and calls the Destroy Component function (just in case the destroy component you mentioned was called on the root component of the effect blueprint) on it.
        I tried it and it didn't work too maybe i do sth wrong

        Comment


          #5
          The actor is getting destroyed when you call the destroy actor node. Hence the reason why the fire particles stop after 5 seconds. But I'm almost certain that this is an issue with the child actor component not being destroyed.

          Try adding this (just for testing) to your monster blueprint's event begin play. Then fire a bullet at the enemy once about 2-3 seconds after the game starts.

          Click image for larger version  Name:	destroycomp.jpg Views:	1 Size:	326.5 KB ID:	1677022
          Tower Defense Starter Kit | Grid Creation Systems | Top Down Stealth Toolkit

          Comment


            #6
            Dude ... it works ! Thanks a lot ! But i dont understand something.

            I can only destroy a child component from his parent actor, i can't from another class ... check the screenshot.

            I don't understand why ...

            Comment


              #7
              is it because the target of the function get component by class take an actor parameter ?

              Comment


                #8
                I wasn't aware of that either. However, upon further inspection, if you hover the cursor & check out the description of "Destroy Component" node, it says that only the actor which owns the component should call this function.

                So it basically works differently from the Add Component node. In that case, since the target is an actor, you can add the component even from other classes as you have already done with the child actor. But with the Destroy Component node, the target is a reference to the component. So I'm guessing that since it doesn't really know that the component is from a different actor, the operation ends up doing nothing.
                Last edited by Stormrage256; 10-23-2019, 07:27 AM.
                Tower Defense Starter Kit | Grid Creation Systems | Top Down Stealth Toolkit

                Comment


                  #9
                  Originally posted by Stormrage256 View Post
                  I wasn't aware of that either. However, upon further inspection, if you hover the cursor & check out the description of "Destroy Component" node, it says that only the actor which owns the component should call this function.

                  So it basically works differently from the Add Component node. In that case, since the target is an actor, you can add the component even from other classes as you have already done with the child actor. But with the Destroy Component node, the target is a reference to the component. So I'm guessing that since it doesn't really know that the component is from a different actor, the operation ends up doing nothing.
                  Well ..... Thank you man, i was stuck for 3 days ... thanks

                  Comment


                    #10
                    Originally posted by Arnaud Roncari View Post

                    Well ..... Thank you man, i was stuck for 3 days ... thanks
                    Happy to help! We all run into those black hole phases every once in a while.
                    Tower Defense Starter Kit | Grid Creation Systems | Top Down Stealth Toolkit

                    Comment

                    Working...
                    X