Announcement

Collapse
No announcement yet.

how to work with destructibles?

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

    how to work with destructibles?

    Hi

    For the past couple of days I've been trying to make the destructibles work, and it seems that the system is either severely bugged, or I'm doing something drastically wrong.
    I looked for some tutorials etc, but found nothing.

    So I'm starting this thread in hope of getting some answers and establishing some ground knowledge on the subject.


    My use case is very simple - I have a character wielding a shotgun, a powerful one at that, and I want to be able to wreak some havoc around.

    Step 1
    At first I tried to create a simple destructible box and have it break after applying some force to it.
    So I selected one of the sample shapes - a box, right clicked on it in the content browser, and selected "Create Destructible Mesh".
    In the destructible editor, I clicked on the 'Fracture' button - not sure if it's needed, but did it anyway.

    Then I placed it on the level, a little above the ground.
    Had to change the settings on the instance in order to get it to be simulated by physics and respond to collisions, but in the end the box started behaving as a regular, collidable static mesh - so far so good.

    Step 2
    I want to apply the simplest force to the object, just make it flip over and break or anything - no C++ code yet.
    So I found a "RadialForceActor" class, which offered just what I was looking for - an ability to apply a force impulse and a damage to the destructibles.

    I made sure that my destructible is withing the range of the force emitter, set the falloff of the later to 'Rif_Constant', and ran the simulation.

    Nothing happened.
    I tried moving the box above the ground to see if it's still falling down - that still worked, but the emitter had no effect on the simulation whatsoever.
    I tried what effect the "RadialForceActor" will have on a regular static mesh box ( with all physics simulation settings enabled ) - NONE WHATSOEVER.


    Step 3
    I took a sneak peek under the hood of how the RadialForceActor is implemented - it runs a query, and applies damage and a force impulse to the components it stumbles upon within its radius of influence.

    So I tried creating a very simple piece of code that would test what components get turned up by a similar query:
    Code:
       
    TArray<struct FHitResult> outHits;
    {
          const float Range = 300.0f;
          FVector shotDir = shooter->GetActorForwardVector();
          FVector start = shooter->GetActorLocation() + shotDir * 200.0f;
          FVector end = start + shotDir * Range;
    
          FCollisionQueryParams params;
          FCollisionShape collisionShape;
          collisionShape.SetSphere( 100.0f );
    
          GetWorld()->SweepMulti( outHits, start, end, FQuat::Identity, ECC_WorldDynamic, collisionShape, params );
    }
    It found hits with static and skeletal components, but not the DestructibleComponent ( even though it was using the same collision group as the rest of my test objects ).

    Step 4
    My last attempt was to try how it work when spawned from a blueprint.
    So I created one based on an Actor class ( I saw that there's a DestructibleActor class available, I'll get to that in a sec ). I added a DestructibleComponent to it, set my shape in it, and placed it on the level.
    The exact same thing happen - I wasn't able to query the component using the cast pasted above. But this time the collision settings I made on the destructible component had no effect either - I could walk through the object.

    Step 5
    I got a bit desperate and started looking for anything that would work.
    My suspicion was that perhaps I'm not using the Sweep correctly. So I tried a bit different approach. I created a custom Actor based class that creates a static mesh component and uses it to query for overlapping objects.

    Here's the code:

    .H
    Code:
    /**
     * A base class for all shotgun-like weapons
     */
    UCLASS()
    class AHatredBaseShotgun : public AActor
    {
    	GENERATED_UCLASS_BODY()
    	
    public:
       // The mesh of the weapon
       UPROPERTY( VisibleDefaultsOnly, Category = Mesh )
          TSubobjectPtr<USkeletalMeshComponent>     ShotgunMesh;
    
    
       /**
        * Fires the weapon.
        *
        * @param shooter          actor shooting the gun
        * @param target        an actor we're shooting at
        */
       void Fire( AActor* shooter, AActor* target );
    };
    .CPP
    Code:
    AHatredBaseShotgun::AHatredBaseShotgun(const class FPostConstructInitializeProperties& PCIP)
    	: Super(PCIP)
       , Damage( 100.0f )
       , ImpulseStrength( 100.0f )
    {
       // shotgun visual mesh
       {
          ShotgunMesh = PCIP.CreateDefaultSubobject<USkeletalMeshComponent>( this, TEXT( "Mesh" ) );
          RootComponent = ShotgunMesh;
       }
    }
    
    void AHatredBaseShotgun::Fire( AActor* shooter, AActor* target )
    {
       // place the damage origin between the shooter and the target, so that it appears
       // the targets gets blown away by the force impulse ( a hack until they implement a linear force impulse )
       FVector origin = target->GetActorLocation();
       FVector impulseDir = origin - shooter->GetActorLocation();
       impulseDir.SafeNormal2D();
    
       // randomize the hit height a bit
       {
          FVector boundsOrigin, boxExtent;
          target->GetActorBounds( true, boundsOrigin, boxExtent );
    
          float randVal = ( float ) FMath::Rand() / ( float ) RAND_MAX - 0.5f;
          origin.Z = boundsOrigin.Z + randVal * boxExtent.Z;
       }
    
       TArray< UPrimitiveComponent* > components;
       target->GetComponents( components );
    
       // Iterate over each and apply an impulse
       const int16 count = components.Num();
       for ( int16 i = 0; i < count; ++i )
       {
          UPrimitiveComponent* pokeComp = components[i];
          if ( pokeComp )
          {
             // If DestructibleDamage is non-zero, see if this is a destructible, and do damage if so.
             if ( Damage > SMALL_NUMBER )
             {
                UDestructibleComponent* destructibleComp = Cast<UDestructibleComponent>( pokeComp );
                if ( destructibleComp != NULL )
                {
                   destructibleComp->ApplyDamage( Damage, origin, impulseDir, ImpulseStrength );
                }
             }
    
             // Do impulse after
             pokeComp->AddImpulseAtLocation( impulseDir* ImpulseStrength, origin );
          }
       }
    
       // also - apply damage to the actor
       FDamageEvent damageEvent( DamageTypeClass );
       target->TakeDamage( Damage, damageEvent, shooter->GetInstigatorController(), shooter );
    }
    'Fire' method is called from my custom Character class.
    Surprisingly, this method managed to turn up overlaps with the Destructibles, even though I didn't change the setup one bit!

    But another problem arose - all objects seemed to 'explode' from within. No measure of force or damage applied, no matter the application method I called ( AddImpulse, AddImpulseAtLocation, AddForce, ApplyDamage, ApplyRadialDamage... ) seemed to change that.

    I soon noticed that this behavior gets even worse when the placed prefab is scaled. The larger the scale of an object, the less predictable the physics was.

    Step 6
    Finally, I tried the DestructibleActor class - just for the sake of trying all available options.
    Even though the class doesn't have any code that would suggest it handling collision and damage in any way - it only provides a setup for a destructible component etc, the behavior I got from it was drastically different to the blueprints based off a simple Actor.

    Even though the 'explosions' looked exactly the same, they seemed to be 'toned down' a notch ( not exploding so violently when the same amount of force and Damage was applied ).

    I could notice that just by changing the base class of the component and then fixing the settings of the attached DestructibleComponent.


    ---------------------------------



    I guess the next step will be to actually debug how the engine executes those queries, but since that will be time consuming, and I'm, really looking for an easy way out here, I thought I'll just ask.


    So to those of you who made it through this long description - thank you, and could you please help me understand what am I ( or the engine ) doing wrong?
    This feature is very important to the project I'm currently working on, and I need to know if the system is flawed, or is it just my lack of knowledge how to set things up that's to blame.

    I would also appreciate links to any available tutorials on the subject.


    Cheers,
    Piotr

    #2
    Destructibles Work Very Well, Video

    Hi there!

    Here's a video I made of moveable destroyable destructible actors from the Beta

    https://wiki.unrealengine.com/Victor...royable_Meshes

    They do work quite well!

    Here's some things to keep in mind:

    0. you don't need a radial force actor

    1. any destructiblemesh can be moveable if you spawn it and set it to simulate physics

    2. there are only 2 damage functions that damage destructible meshes, they are in UDestructibleComponent

    Code:
    // Take damage
    UFUNCTION(BlueprintCallable, Category="Components|Destructible")
    void ApplyDamage(float DamageAmount, const FVector& HitLocation, const FVector& ImpulseDir, float ImpulseStrength);
    
    // Take radius damage
    UFUNCTION(BlueprintCallable, Category="Components|Destructible")
    void ApplyRadiusDamage(float BaseDamage, const FVector& HurtOrigin, float DamageRadius, float ImpulseStrength, bool bFullDamage);

    3. Recommended Solution

    Extend DestructibleActor

    or simply remake it

    and then you have total control


    I JUST finished doing this in my own project and it works perfectly



    Rama
    100+ UE4 C++ Tutorials on the UE4 Code Wiki, including UE4 Multi-Threading!

    UE4 Marketplace: Melee Weapon Plugin & Compressed Binary Save System Plugin | Rama's C++ AI Jumping Videos | Vertex Snap Editor Plugin

    Visit www.ue4code.com to see lots of videos about my C++ Creations! ♥ Rama

    Comment


      #3
      Hi Rama

      Actually, your video shows the exact problems I desribe.
      All objects seem to explode ( 0:26s for instance ). I can't apply any force that would 'push the debris in a single direction ( the reaction you would expect to a shotgun shot ).

      Moreover - certain shapes of objects ( pillars ) do exhibit such behavior, whilst other ( broad walls ) simply explode, even though the same amount of force or damage is applied, and they have the exact same destruction thresholds set.


      Another problem is querying for the destructible components. Sweep checks don't turn them up!!


      Could you please share some of your code or settings to actually illustrate how you achieved your results?
      I would appreciate that.

      Thanks,
      Piotr

      Comment


        #4
        "Moreover - certain shapes of objects ( pillars ) do exhibit such behavior, whilst other ( broad walls ) simply explode, even though the same amount of force or damage is applied, and they have the exact same destruction thresholds set."

        you need multiple debris depth layers

        and then you change what the minimum fracture depth is

        if you dont want the entire thing to explode

        what you are decribing as a "problem" was actually my own personal intended design, to have different results you need to look deeply into the apex settings

        this is not as much an UE things as it is a Nvidia thing

        you should go to their youtube on apex destructibles to learn how to only fracture parts of a mesh, and then you can use UE's inhouse support for these features in the destructible editor


        As far as how I achieved my results, I already posted the relevant code

        you can just spawn an ADestructibleActor and you are good to go

        Rama
        100+ UE4 C++ Tutorials on the UE4 Code Wiki, including UE4 Multi-Threading!

        UE4 Marketplace: Melee Weapon Plugin & Compressed Binary Save System Plugin | Rama's C++ AI Jumping Videos | Vertex Snap Editor Plugin

        Visit www.ue4code.com to see lots of videos about my C++ Creations! ♥ Rama

        Comment


          #5
          Originally posted by Rama View Post
          you need multiple debris depth layers

          and then you change what the minimum fracture depth is

          if you dont want the entire thing to explode

          Rama
          Hi

          You're missing the point - I don't mind that the entire thing breaks, and not only a part of it.

          What I do mind is that I can't 'channel' that explosion in a specific direction. That after the shape breaks apart, the debris falls around it.

          Please mind what I'm trying to achieve here - a shotgun like effect. I want to stand close to an object, shoot at it, and have all debris burst in a cone-like shape in the direction I'm shooting in.


          Correct me if I'm wrong, but the system works in 2 stages:

          Stage 1. It needs to receive certain amount of damage before it breaks. Until that point, the object stays intact as a whole ( on a certain destruction level of course ).

          Stage 2. The threshold damage value is reached and the object is disassembled to debris.

          Now - what I wonder is what simulates the further movement of the debris pieces? I was under impression that physics simulation drives them - but that would mean they would react to external forces.
          But my attempts to apply such forces or impulses resulted in widely unpredictable behaviors - and that unpredictability had much to do with whether scale was applied to the object and of its shape.


          The other thing, even more important one - is that there's no way to query for a standalone Destructible object placed on the level.
          To put it in simplest terms - if I turn a static mesh, drag it to the level, assign it a proper collision group and run any kind of level query ( SweepMulti, SweepSingle... ) over its position, the object simply doesn't turn up.

          The only way it works is to put a destructible mesh inside of a blueprint, in a DestructibleComponent.
          Would you happen to know if that's by design - is that the only way we can make the queries pick up destructibles - put them in bluerprints?
          Not that it's not acceptable, but I'd like to know beforehand - the designers would also appreciate the knowledge I guess.


          I really appreciate you taking your time to help me. I hope I can reach as good results as you did in your demo.

          Cheers,
          Piotr

          Comment


            #6
            "Now - what I wonder is what simulates the further movement of the debris pieces? I was under impression that physics simulation drives them - but that would mean they would react to external forces."

            you absolutely can channel the destructible pieces in a direction

            see the function definition here:

            Code:
            // Take damage
            UFUNCTION(BlueprintCallable, Category="Components|Destructible")
            void ApplyDamage(float DamageAmount, const FVector& HitLocation, const FVector& ImpulseDir, float ImpulseStrength);
            which I posted for you above

            you want this
            Code:
            const FVector& ImpulseDir, float ImpulseStrength
            My newest version of my code does have this channeling in one direction effect going


            "The other thing, even more important one - is that there's no way to query for a standalone Destructible object placed on the level."

            yes there is!

            See my wiki tutorial here on finding objects in the world:

            Object Iterator

            https://wiki.unrealengine.com/Iterat..._Faster_Search
            100+ UE4 C++ Tutorials on the UE4 Code Wiki, including UE4 Multi-Threading!

            UE4 Marketplace: Melee Weapon Plugin & Compressed Binary Save System Plugin | Rama's C++ AI Jumping Videos | Vertex Snap Editor Plugin

            Visit www.ue4code.com to see lots of videos about my C++ Creations! ♥ Rama

            Comment


              #7
              Yes, I 've already tried it - doesn't work. Doesn't work with wall-like objects to be specific. They burst all around, and I'm also noticing the pieces going back to the explosion origin, like bumerangs.


              Here's the method:
              Code:
              void AHatredBaseShotgun::Fire( AActor* shooter, AActor* target )
              {
                 // place the damage origin between the shooter and the target, so that it appears
                 // the targets gets blown away by the force impulse ( a hack until they implement a linear force impulse )
                 FVector origin = target->GetActorLocation();
                 FVector impulseDir = origin - shooter->GetActorLocation();
                 impulseDir.SafeNormal2D();
              
                 // randomize the hit height a bit
                 {
                    FVector boundsOrigin, boxExtent;
                    target->GetActorBounds( true, boundsOrigin, boxExtent );
              
                    float randVal = ( float ) FMath::Rand() / ( float ) RAND_MAX - 0.5f;
                    origin.Z = boundsOrigin.Z + randVal * boxExtent.Z;
                 }
              
                 TArray< UPrimitiveComponent* > components;
                 target->GetComponents( components );
              
                 // Iterate over each and apply an impulse
                 const int16 count = components.Num();
                 for ( int16 i = 0; i < count; ++i )
                 {
                    UPrimitiveComponent* pokeComp = components[i];
                    if ( pokeComp )
                    {
                       // If DestructibleDamage is non-zero, see if this is a destructible, and do damage if so.
                       if ( Damage > SMALL_NUMBER )
                       {
                          UDestructibleComponent* destructibleComp = Cast<UDestructibleComponent>( pokeComp );
                          if ( destructibleComp != NULL )
                          {
                             destructibleComp->ApplyDamage( Damage, origin, impulseDir, ImpulseStrength );
                          }
                       }
              
                       // Do impulse after
                       pokeComp->AddImpulseAtLocation( impulseDir* ImpulseStrength, origin );
                    }
                 }
              }
              The application of physical impulse afterwards serves the purpose of propelling 'regular' mesh components, as well as ( I was hoping that would work ) telling the Destructible components that it's under influence of a force and should behave as such.


              But let's not forget - how do you actually query for the destructibles? Do you have them blueprinted, or do you place Destructibles on the level directly?
              What method do you use to query for them?

              Here's what I tried:

              Doesn't work niether for standalone Destructibles nor the ones embedded in Blueprints
              Code:
                 
              TArray<struct FHitResult> outHits;
                 {
                    const float Range = 10000.0f;
                    FVector shotDir = shooter->GetActorForwardVector();
                    FVector start = shooter->GetActorLocation(;
                    FVector end = start + shotDir * Range;
              
                    FCollisionQueryParams params;
                    FCollisionShape collisionShape;
                    collisionShape.SetSphere( 100.0f );
              
                    GetWorld()->SweepMulti( outHits, start, end, FQuat::Identity, ECC_Destructible, collisionShape, params );
                    // I tried several other collision layers, even though my destructibles all use this layer assignment - none of them worked
                 }

              Works only for the descructibles embedded in Blueprints
              Code:
                 
              TArray< AActor* > overlappingActors;
              ShotgunFireConeMesh->GetOverlappingActors( overlappingActors ); // ShotgunFireConeMesh is an auxiliary, invisible static mesh component attached to my character


              EDIT: just saw your addition about the iterators - I don't want that. I want to be able to query a specific point on the level in search for destructibles. I want to use broadphase for that if possible.
              The reason is that we plan on having large levels with lots of destructibles in them.

              The other reason - we need to know how to manufacture them - arranged in prefabs, or is there posibility to place them ont he level directly.

              Appreciate your help
              Piotr
              Last edited by Piotr Trochim; 04-04-2014, 05:34 PM. Reason: additional information added to the previous post

              Comment


                #8
                Hopefully others can assist you further

                Rama
                100+ UE4 C++ Tutorials on the UE4 Code Wiki, including UE4 Multi-Threading!

                UE4 Marketplace: Melee Weapon Plugin & Compressed Binary Save System Plugin | Rama's C++ AI Jumping Videos | Vertex Snap Editor Plugin

                Visit www.ue4code.com to see lots of videos about my C++ Creations! ♥ Rama

                Comment


                  #9
                  Sorry to join this discussion late, but I was out last week and am just catching up with it. I lead the destruction effort at NVidia and have helped with the initial integration of APEX into UE4. I hope I can be of some assistance, however many of your questions deal with differences in behavior between destructibles in blueprints, and those not in blueprints. I'm not an expert in that matter, and hopefully someone who is would be kind enough to chime in. I'll try to help with what I do know. Besides queries, which seem to be working to a degree for blueprints, your other concern seems to be force application. This can be a tricky matter to tune, as what can often happen for chunks to receive an impulse, hit neighboring chunks, and bounce back. Also, if for some reason the collision hulls have large initial overlaps, they'll tend to cause an explosion when turned dynamic. Finally, there is a badly-named parameter in APEX destruction, "fractureImpulseScale," whose job it is to "blow out" chunks once they're turned dynamic. It's purely an effect, used for example with a tile floor. Smashing the floor tends to leave the tiles relatively unmoved, however dynamic and broken apart. The fractureImpulseScale helps blow them out of the floor for better dramatic effect. If that's accidently on, you might be seeing this effect. However the default value is zero. (It's tied to "FractureImpulseScale" in UE4.) Would it be possible for you to capture some of the bad behavior in PVD, and send a capture file? It could help us understand exactly what's going on with the physics simulation.

                  The issue was also brought up regarding the entire destructible being blown apart, although you dismissed this as not a primary concern. I will point out that in APEX 1.3 and later, we have a method for delivering better control of the damage radius to destructibles. However, UE4 does not yet use this feature, and has the legacy (1.2.x) behavior enabled. This is done with these lines in PhysLevel.cpp:

                  // APEX 1.3 to preserve 1.2 behavior
                  GApexModuleDestructible->setUseLegacyDamageRadiusSpread(true);
                  GApexModuleDestructible->setUseLegacyChunkBoundsTesting(true);

                  The new damage system uses new parameters in the chunk behavior groups. See DestructibleMesh.cpp, and search for defaultBehaviorGroup. You'll see that defaultBehaviorGroup.damageToRadius is used, and this is the parameter that describes how far damage spreads in a destructible, in the old (legacy) system. In the new system, we have damageSpread.minimumRadius, damageSpread.radiusMultiplier, and damageSpread.falloffExponent. (All of these are under defaultBehaviorGroup.) Here is a description of the old and new systems:

                  • Old: there is damageToRadius. When damage is taken, it’s divided by the damage threshold, and multiplied by damageToRadius, and yet *again* by a “size scale” (the radius of the actor’s bounding sphere). This gives a final radius. If there is no falloff, the damage is applied equally to all chunks in that radius. If there is falloff, it’s linear from the point of application, falling to zero at the final radius. That was for point damage. For radius damage, the same holds true except that the input damage radius is added to the final radius.

                  • New: the user provides a minimumRadius, radiusMultiplier, and falloffExponent. A maximumRadius is calculated from:

                  maximumRadius = minimumRadius + radiusMultiplier*inputRadius

                  The inputRadius is 0 for point damage, and something positive for radius damage, provided by the user. For point damage, falloff isn’t used. For radius damage, falloff is used in this way:

                  effectiveDamage = inputDamage*pow( (maximumRadius – chunkDistance)/(maximumRadius – minimumRadius), falloffExponent )

                  The chunkDistance is the distance to the chunk from the applied damage position. (This depends on whether or not you’re using the legacyChunkBoundsTesting – old = use chunk centroid, new = actual distance from damage position to nearest point in chunk’s collision hulls.)

                  There’s a caveat, in that impact damage still uses the old damageToRadius field, and scales damage by the damageThreshold, but does *not* scale the radius by the actor’s size.

                  We're talking with Epic about moving to the new system, along with a reasonable way to deprecate the old parameters. In the meanwhile, this may be an avenue you'd like to pursue in your codebase if you'd like better control of the damage radius.

                  I hope this was of some help,

                  Bryan Galdrikian

                  NVidia

                  Comment


                    #10
                    Hi Bryan,

                    Thanks for the valuable input. I was also studying the effect those parameters had on the simulation, and together with an artist I'm working with we managed to get the fractures to break more or less the way we want to, specifically with the use of the 'fractureImpulseScale' param you mention.

                    However my main concern here is the huge inconsistencies in the way the system reponds to various 'force' and 'damage; inputs.
                    I started studying the code, but since I'm doing it in my spare time, it's not going so quickly as I'd like, but let me share my findings and my current concerns.

                    I'll elaborate soon, I need to do a few more tests though, but mainly it boils down to what I've already described, with addition of a few extra things, like not being able to tell when a destructible object's already been broken and we don't want its chunks responding to the force impulse ( it works with the character capsule, I need to dig in that code to see what they do etc ).

                    The fact that there's absolutely no documentation whatsoever that would explain the components of the system and their desired behaviors makes this investigation feel like walking in a very dark forest.


                    Anyway - thanks for the input.
                    Piotr

                    Comment


                      #11
                      So I did some more tests, and it basically boils down to this - scaled objects break physics.
                      When the objects were exported in the correct scale, physics started responding predictably - no weird explosions etc.

                      There's still a problem with the collision filtering however. Some of the settings just don't work with destructibles.

                      An example - a destructible wall that I'm using has the default collision presets applied:
                      Click image for larger version

Name:	wallSettings.JPG
Views:	1
Size:	23.3 KB
ID:	1050103

                      I needed to modify my character's collision settings slightly to make him collide with the wall:
                      Click image for larger version

Name:	characterSettings.JPG
Views:	1
Size:	68.9 KB
ID:	1050104

                      So I wanted to create a projectile that would be launched into the destructible, and when it crashed into it, it would generate an overlap event in response to which I could do something.
                      So I spawned a blueprint of an actor with a SkeletalMeshComponent and a ProjectileMovement component in it.
                      Initially I set the skeletal's component's collision filter settings to the exact same as for the character, thinking "ok, even though it's not a Pawn, this one's been proven to work", and placed the blueprint on the level.

                      Here's a screenshot of those collision settings:
                      Click image for larger version

Name:	projectileSettings.JPG
Views:	1
Size:	32.6 KB
ID:	1050105

                      .. and a simple blueprint that should output a debug message on screen if an overlap took place ( or maybe the log, who knows how this thing works, so I checked both just to be sure):
                      Click image for larger version

Name:	blueprint.JPG
Views:	1
Size:	22.4 KB
ID:	1050106


                      As you can imagine nothing happened, even the blueprint debugger didn't show any signal flow on the latter, which means that the overlap wasn't recorded when the actor was passing through the destructible.

                      So here's the thing - how come do the same collision filter settings work for one component of one actor, and don't for the other?


                      Hope someone will be able to explain.

                      Btw - I tried debugging what's going on, but it's very difficult to come up with any debugging scenario for a case where something doesn't collide, because:

                      1. the code is called every frame, and the time keeps on flowing - so you pauset he execution for a while longer on a breakpoint, and your body ends up far far away in the next, 'cause so much time's passed.

                      2. if there's no collision, then there's no collision - o the context doesn't change in any way when my body passes through the destructible in any way that could let me set up a conditional breakpoint.

                      I was analyzing the GeomOverlapMulti, which seems to be at the heart of USkeletalMeshComponent::ComponentOverlapMulti.
                      So any pointers as to the debugging strategy of such a problem would also be appreciated.

                      Thanks,
                      Piotr

                      Comment


                        #12
                        Piotr, I unfortunately am far less competent on this issue than others in this thread to help you, however I do suggest you open a bug report in the AnswerHub about your findings to ensure it is followed up by Epic.
                        It is by will alone I set my code in motion.
                        It is by coding that thoughts acquire speed, the hands acquire shaking, the shaking becomes a warning.
                        It is by will alone I set my code in motion.

                        Comment


                          #13
                          I already have - back when I started this thread. No one's picking up I guess...

                          Comment


                            #14
                            I just want to summarize the problem you are currently hitting:
                            1) You say 'scaled objects break physics'. Could you give us a good repro so we can work on the problem here? What issues do you see when you scale the object? Non-uniform scaling is currently not supported I'm afraid.
                            2) You are not getting overlap events from destructibles, is that correct? Did you try using a simple component for the projectile collision like a sphere component, rather than a skeletalmeshcomponent (which requires a physics asset for collision)? Are you able to get hit events instead of overlap events if you set the collision up to block the projectile?
                            Lead Programmer - UE4 Animation/Physics/Audio Team - Epic Games
                            Twitter: @EpicJamesG

                            Comment


                              #15
                              Hi James,

                              Thanks for answering.

                              Ad 1) If I apply a non-uniform scale to, say, a destructible box, and then I make the box explode, the chunks fly away in a weird, unnatural manner.
                              Ad 2) Neither the USkeletalMeshComponent, nor the UStaticMeshComponent or the USphereComponent notify about the overlap events. I tested it with different collision layer settings of course, and nothing works.

                              The hit events are not generated either - the "Generate Hit Events" flag was set to true of course. Even if I enable physical collision, the event is not generated.

                              Here's a sample code that I used to set up the USphereComponent to yield callbacks on both:
                              Code:
                                    CollisionShape = PCIP.CreateDefaultSubobject<USphereComponent>( this, TEXT( "Shape" ) );
                                    CollisionShape->SetCollisionEnabled( ECollisionEnabled::QueryOnly );
                                    CollisionShape->BodyInstance.SetCollisionProfileName( "OverlapAll" ); // tested also with BlockAll
                                    CollisionShape->OnComponentBeginOverlap.AddDynamic( this, &AHatredBaseProjectile::OnProjectileOverlap );
                                    CollisionShape->OnComponentHit.AddDynamic( this, &AHatredBaseProjectile::OnProjectileHit );
                                    CollisionShape->AttachParent = Mesh;
                              And here are the callback functions signatures:
                              Code:
                                 UFUNCTION()
                                    void OnProjectileOverlap( AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex );
                                 UFUNCTION()
                                    void OnProjectileHit( AActor* OtherActor, UPrimitiveComponent* OtherComp, FVector NormalImpulse, const FHitResult& Hit );
                              What might be wrong here?

                              Thanks,
                              Piotr

                              Comment

                              Working...
                              X