Announcement

Collapse

The Infinity Blade Forums Have Moved

We've launched brand new Infinity Blade forums with improved features and revamped layout. We've also included a complete archive of the previous posts. Come check out the new Infinity Blade forums.
See more
See less

Resizing a KActor

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

  • Resizing a KActor

    Hi all! For my game I'm trying to do physics simulation with rigidbodies which can be resized during gameplay. To do that I created a subclass of KActor and I'm changing their size using SetDrawScale3D().

    I change the size gradually inside Tick() to get smooth results and I was hoping that would also help with the physics as a sudden size change obviously cannot work for physical reasons.

    The visual result is now very pleasing with objects slowing growing to reach twice their size. However it appears the internal physics simulation just does not update at all - the large objects still behave like they'd have their original size and weight.

    I tried multiple things: SetCollisionSize (does not help as KActor does not seem to use a collision cylinder), Re-Init physics by InitRBPhys(); on the object (makes no difference), ForceUpdateComponents() ... nothing helped.

    The only thing that partially works is reattaching the Mesh with StaticMeshComponent.SetStaticMesh() after changing the DrawScale3D. However this leads to errors in the log I don't really understand:

    Code:
    [0224.69] Log: WARNING: Cooking Convex For Actor: UEDPIESP_Test.TheWorld:PersistentLevel.BY2_KActor_12 Component: StaticMeshComponent_1 StaticMesh: Adis_testpackage.static_meshes.testblock (Scale: 2.800000 4.274292 4.274292) Please go and set PreCachedPhysScale on the mesh to have this scale for RunTime spawned objects
    .
    Another problem with reattaching the Mesh is that is resets the physics state which is not what I want and I loose all the restraints. I could recreate that stuff, but reattaching the Mesh also seems a waste of processing power.

    I hope there is some better solution. Has anyone achieved what I'm trying to do here? Any help would be greatly appreciated.

  • #2
    As a general optimisation PhysX expects the size of an object to remain constant, and it pre-calculates this for each mesh. The warning you're getting refers to PreCachedPhysScale, which is an array of sizes you can fill out for the StaticMesh in the editor.

    Comment


    • #3
      Ok thanks! Is there a way I can tell PhysX that the size of an Object has changed?

      Comment


      • #4
        There was a thread sometime ago... try an advanced search for "DrawScale KActor" or something similar.

        Comment


        • #5
          Thank you Spoof.

          I tried locating that thread, but unfortunately I had no success. I found many threads about resizing Pawns, but only one about KActor and that was just the same question without answer.
          Do you have any additional information about how I could find this old thread?

          In the meantime I had some success by replacing the mesh with SetStaticMesh and then reconstructing as much of the physics state as possible. It's important to wait a few Ticks after each mesh replacement to give PhysX some time to move the larger Mesh out of the Ground.

          Comment


          • #6
            I think this is the one. I had to use Google to find it, the forum's own search suffers from amnesia.

            The last post claims some solution of sorts, but I don't know how much mileage you'll get from it.

            Comment


            • #7
              Thanks a lot! Also it's good to know I should always use google to search these forums

              The final solution is more or less what I have found by myself by now. As I already wrote it's important to give the physics some time to "adjust" to the new size. In the meantime I added some code that changes the location so the change in scale does not lead to overlaps with the ground even if the object is lying there at an angle. I now think it is possible to get this to work completely with unrealscript, but I'll need to spend some more hours on it and will then post results here.

              Comment


              • #8
                Maybe you could double-buffer the collision component to fix the 'time to adjust' issue. Also, have you tried adding a sequence of values for PreCachedPhysScale?

                Comment


                • #9
                  I added numerous values to PreCachedPhysScale and made sure the object is only resized to defined steps which does take care of the console warnings. however.. I had to input all those values in the editor. Right now I use 10 steps to scale to double size and I definitely need more steps. Unfortunately PreCachedPhysScale is a const array, so I see no way to populate this in code. That for now means entering 3 values for each step in the editor - that's a bit annoying and what's worse is that resizing a placed object in the editor leads to all the steps being off as UDK doesn't seem to premultiply the PreCachedPhysScale array with the individual actor sizes.

                  Comment


                  • #10
                    Answering my own post I think I might just have found a way after posting the last post. I realized that the warning only shows up once for every size, so now I'm pondering to just scale the objects through all the needed sizes before the game starts. This will output a lot of warnings, but the result will be that the needed sizes will be pre-cached. Setting the actor to a new size seems to lead to a new entry in PreCachedPhysScale, so it's an indirect way to change that array from code.

                    Comment

                    Working...
                    X