Announcement

Collapse
No announcement yet.

How do I destroy an Actor when it touches any other Actor/Mesh?

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

    How do I destroy an Actor when it touches any other Actor/Mesh?

    Hi everyone, I'm a student making a game that involves spells, and I wanted this spell of mine to be destroyed the moment it touches any actor or anything in the game environment, basically. What would be the ideal way to do that?
    I've tried experimenting with Actor Begin Overlap and also collision presets, but since I haven't learnt about those in detail I'm a bit lost. I hope I can get some help here.

    #2
    This will do the trick.
    Click image for larger version

Name:	Bullet.png
Views:	451
Size:	24.3 KB
ID:	1665087
    | Home | ShootOut (WIP) |

    Comment


      #3
      Originally posted by silik1 View Post
      This will do the trick.
      Click image for larger version

Name:	Bullet.png
Views:	451
Size:	24.3 KB
ID:	1665087
      Hey there! Thanks for your suggestion. Unfortunately, it didn't work. I remember trying this out myself. Do any of my component/actor properties need to be changed in order for this to work?

      Comment


        #4
        Yea, You have to tweak Collisions channel of the sphere collission component, to be sure it triggers on the actors/Objects/Component you want.
        Also, be sure it doesn't hit its own mesh(Set Collision off) or any of its own component...

        for this simple exemple above I made an Actor BulletBP with a SphereCollision and a StaticMesh (for visibility).
        The staticMesh has nocollision, the Sphere is as follow, anything that block will trigger the Hit, here only Pawns
        Click image for larger version

Name:	Collision.png
Views:	440
Size:	40.6 KB
ID:	1665097
        | Home | ShootOut (WIP) |

        Comment


          #5
          Make sure to check the collision box for BOTH objects.

          Comment


            #6
            Okay so I have created a new collision preset called 'Environment', and it's supposed to Block everything. I've also created an object type called Spells. I've applied the Environment preset to a wall in my game, so it should block the spell; but it's not. The spell still passes through. Here are a few screenshots (I realised I'd forgotten to check the 'Block' check box in Collision Responses after I took the screenshots, but checking it didn't make a difference either).

            The first image contains my spell's component structure.

            The second image contains my Environment preset.

            The third image contains the collision settings of my spell's sphere collision.

            The fourth image contains the collision settings of my spell's static mesh.
            Attached Files

            Comment


              #7
              Here the set up I came with to test quickly test your question earlier:

              Click image for larger version

Name:	bullet2.png
Views:	493
Size:	221.0 KB
ID:	1666195

              The static mesh has no collision.
              | Home | ShootOut (WIP) |

              Comment


                #8
                Maybe use a cast if it's an actor which you play

                Comment


                  #9
                  Originally posted by silik1 View Post
                  Here the set up I came with to test quickly test your question earlier:

                  Click image for larger version

Name:	bullet2.png
Views:	493
Size:	221.0 KB
ID:	1666195

                  The static mesh has no collision.
                  Yes I've used the collider in my blueprint as well. I've used the exact same nodes. I've also made sure my static mesh has collisions. I've attached a screenshot below.
                  Attached Files

                  Comment


                    #10
                    if your wall is a custom mesh you imported, make sure it has collision at all. Find the StaticMesh, doubleclick and check if it has a collision box...
                    Anyway, I'd say it's better to implement something individually, test and then add more stuff.

                    For exemple, you wanna throw a ball which will be destroyed when it hits a wall?
                    Don't implement the whole thing in a shot.
                    Let's say:
                    Work your magicball, throw it on a default wall. It works? Great!
                    Now import your own wall if it doesn't work, you'll know the issue is not the ball...

                    That would be my workflow, one thing at a time. Nothing worst to search issue where there is no.
                    | Home | ShootOut (WIP) |

                    Comment


                      #11
                      Originally posted by silik1 View Post
                      if your wall is a custom mesh you imported, make sure it has collision at all. Find the StaticMesh, doubleclick and check if it has a collision box...
                      Anyway, I'd say it's better to implement something individually, test and then add more stuff.

                      For exemple, you wanna throw a ball which will be destroyed when it hits a wall?
                      Don't implement the whole thing in a shot.
                      Let's say:
                      Work your magicball, throw it on a default wall. It works? Great!
                      Now import your own wall if it doesn't work, you'll know the issue is not the ball...

                      That would be my workflow, one thing at a time. Nothing worst to search issue where there is no.
                      So right now, my wall does have collisions, because my player character gets blocked when he walks into it. So I know the collision of the wall isn't the problem..
                      Also, I put out a Print String to check if On Component Hit (Sphere) gets called or not, but it doesn't. That's really odd. Despite me specifying that every collision has to be blocked, the Sphere isn't hitting anything in the game. My wall has also been instructed to block everything.

                      Does it make a difference if my Spell has got a Projectile Movement component?
                      Last edited by Soul_Martini; 09-20-2019, 01:11 AM.

                      Comment


                        #12
                        Originally posted by Soul_Martini View Post

                        Does it make a difference if my Spell has got a Projectile Movement component?
                        Nope.
                        You should create a new Blueprint project, using FirstPerson Template. Navigate to the Projectile blueprint, right click>>Asset Action>>Migrate to your own project.
                        Then use it as a base for your own.
                        | Home | ShootOut (WIP) |

                        Comment


                          #13
                          Originally posted by silik1 View Post

                          Nope.
                          You should create a new Blueprint project, using FirstPerson Template. Navigate to the Projectile blueprint, right click>>Asset Action>>Migrate to your own project.
                          Then use it as a base for your own.
                          I checked out the Collision Presets, object types, etc. of the FirstPerson Template. I tried implementing those in my game as well with respect to the environment as well as my spell. Nothing seems to work. I'm just at a loss for ideas.

                          Comment


                            #14
                            These Collisions are okay right? I've checked the 'Customized Collision' checkbox, and I've also selected 'Use Complex Collision as Simple' in the Collision Complexity options.
                            Attached Files

                            Comment


                              #15
                              Looks good to me
                              You know, your projectile mesh doesn't need collision, the SphereCollision component in the Blueprint should take care of it.
                              | Home | ShootOut (WIP) |

                              Comment

                              Working...
                              X