Announcement

Collapse
No announcement yet.

Plugin Object Pool Component

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

    Hi Bruno,
    I do spawn cars 25-30 at a time and when they have completed the run they are destroyed, however it seems that you are saying the plug in saves performance during the spawn operation not during the running, in which case the plugin will not help,
    I have no slow downs or difficulty in spawning / destroying as they spawn out of site/gameplay area at 1sec intervals to make up the train.
    Sorry if I grabbed the wrong end of the stick I was unsure if the pool object offered any phys performance benefits.....(why I asked for clarification)
    THanks
    Paul_G

    Comment


      If you're spawning ~30 cars every second then yes, the plugin will definitely help with performance.
      Will always be better to spawn the wagons from the Pool than delete/re-create them in such a short period of time.
      | Savior | USQLite | FSM | Object Pool | Sound Occlusion | Property Transfer | Magic Nodes | MORE |

      Comment


        I was just using your example code, so please fix this for all of us in the future yourself, too !
        It wasn't my idea to do it this way, i saw your code and changed it !

        And yes ! This really fixes the issue !
        So i just have to implement my old bullet again, that's quite fine
        Attached Files
        Last edited by Held0fTheWelt; 11-09-2018, 05:10 AM.

        Comment


          Next update shall prevent that from happening.
          I removed that function from Post Load.
          | Savior | USQLite | FSM | Object Pool | Sound Occlusion | Property Transfer | Magic Nodes | MORE |

          Comment


            Another thing, i cannot do, is, when having a blueprint from my C++ class, setting up the value for LifeSpanPool leads to crashing the system.
            I implemented my own TimerDelay this way, which is working handy:

            Code:
                UPROPERTY(EditDefaultsOnly, Category = "Setup")
                float ReturnDelay = 5.f;
            
                UFUNCTION()
                void OnTimerExpire();
            
            Inside Shoot_Implementation:
                if (ReturnDelay != 0.0f)
                {
                    FTimerHandle Timer;
                    GetWorld()->GetTimerManager().SetTimer(Timer, this, &APooledCannonProjectile::OnTimerExpire, ReturnDelay, false);
                }
            
            void APooledCannonProjectile::OnTimerExpire()
            {
                ReturnToPool();
            }

            Comment


              Now it's falling to the ground, even if it is not breaking up everything...

              Tell me, what you have fixed to use your implementation, or is anybody of help to get my projectile up running ???

              Attached Files

              Comment


                Setup your physics channels correctly.
                Your bullets are just hitting each other in the pool, you should make them ignore their own collision channel.
                | Savior | USQLite | FSM | Object Pool | Sound Occlusion | Property Transfer | Magic Nodes | MORE |

                Comment


                  This doesn't make my MovementComponent work !
                  They are spawning correctly, but then just drop to the ground and after hitting the ground returning to the pool.

                  Comment


                    Looking into the demo project might help.
                    There's something in your blueprints you're missing.
                    Maybe try to disable their gravity until the projectile leaves its owner?

                    Also check velocity (direction) vector.
                    It shouldn't be a 0,0,0 vector...
                    | Savior | USQLite | FSM | Object Pool | Sound Occlusion | Property Transfer | Magic Nodes | MORE |

                    Comment


                      BLT->ProjectileMovementComponent->SetVelocityInLocalSpace(FORWARDVECTOR * LaunchSpeed);

                      I am not moving it with blueprint, nor changing settings in blueprint !

                      Another thing, i don't get is, how to choose which object i wanted to take away from a shared pool.
                      How would i say, i now want to spawn an object placed in the second array slot for pooled actors ?
                      I have that information, that i wanted to do it, but i don't know, how to ask the shared pool for it.
                      I found :
                      static APooledActor* BeginDeferredSpawnFromPool(const UObject* WorldContextObject, USharedObjectPool* SharedPool, UClass* Class, const FPoolSpawnOptions &SpawnOptions, const FTransform &SpawnTransform, ESpawnActorCollisionHandlingMethod CollisionHandlingOverride, AActor* Owner, const bool Reconstruct, bool &SpawnSuccessful);

                      But which UClass Pointer should be inserted there ?
                      In both cases there are the same classes in, with completely different value settings.

                      Comment


                        If second array is, say, "ABlueBullet"...
                        On UClass* param for spawn function input ABlueBullet::StaticClass()
                        | Savior | USQLite | FSM | Object Pool | Sound Occlusion | Property Transfer | Magic Nodes | MORE |

                        Comment


                          All three classes are APooledExplosion with ParticleEffect and Soundcue Playsettings
                          I have worked around this by setting up three values to identify my blueprint

                          UPROPERTY(EditDefaultsOnly, Category = "Setup")
                          UClass* Cannon;

                          UPROPERTY(EditDefaultsOnly, Category = "Setup")
                          UClass* Gun;

                          UPROPERTY(EditDefaultsOnly, Category = "Setup")
                          UClass* Missile;

                          UClass* currentClass = nullptr;

                          if (CannonType == 0)
                          currentClass = Cannon;
                          if (CannonType == 1)
                          currentClass = Gun;
                          if (CannonType == 2)
                          currentClass = Missile;

                          If i would insert just APooledExplosion, this doesn't help.
                          Isn't there a possibility to just grab 0 ?

                          Btw.: My MovementProblem still is unsolved !
                          Working with your class and PooledProjectile worked quite fine, except the little thing about crashing my editor.

                          If you have a workaround for me, i really would like to take away the PooledProjectile case, but i don't know how to fix that now, your small comment did not lead me.
                          Right now everything just pees out of my muzzle and falls to the ground, because physics are active.
                          Last edited by Held0fTheWelt; 11-09-2018, 11:28 PM.

                          Comment


                            Look at MovementComponent source.
                            It needs a valid velocity vector to move or it won't gain speed from Tick.
                            Since you are doing things in C++ I have no idea what you're missing.
                            | Savior | USQLite | FSM | Object Pool | Sound Occlusion | Property Transfer | Magic Nodes | MORE |

                            Comment


                              It looks like everything is set, all velocities match, but my static mesh component isn't influenced by it in any case ...
                              In the blueprint, it flies away, but it doesn't after spawning ...
                              And you have seen all code, which is first based on your sample and a projectile, that did fly without object pool.

                              Comment


                                Originally posted by Held0fTheWelt View Post
                                It looks like everything is set, all velocities match, but my static mesh component isn't influenced by it in any case ...
                                In the blueprint, it flies away, but it doesn't after spawning ...
                                I think someone around page 5 to 7 in this forum topic had same problem as you.
                                But I don't remember if he explained what was bugging his setup, maybe wrong physics settings or he wasn't calling Super::PoolBeginPlay on his Blueprints, I'm not sure.

                                _____

                                By the way, are you sure you are executing APooledActor::FinishSpawnFromPool(...) after you spawn your PooledActor from C++ with APooledActor::SpawnFromPool(...) ??

                                After calling BeginDeferredSpawnFromPool(...) you have to call FinishDeferredSpawnFromPool(...) to complete the routine otherwise everything bugs out.
                                Last edited by BrUnO XaVIeR; 11-11-2018, 11:54 AM.
                                | Savior | USQLite | FSM | Object Pool | Sound Occlusion | Property Transfer | Magic Nodes | MORE |

                                Comment

                                Working...
                                X