Object Pool and Starting Movement again

Hello!!

So I have created an object pooling system. Essentially, you will fire a projectile, it gets added to the pool, and when you fire again it will check if a projectile exists in the pool array and then attempt to reuse this projectile. This projectile, on hit will get hidden and have collision removed and it will also have an ‘in use’ variable set to true once its used. Once it makes contact with a wall or an AI, it will have the ‘in use’ variable set to false again waiting to be pulled from the array.

The issue I am having is that when it pulls that projectile out, it does not move in the forward direction it is supposed to. It actually does not move at all. I am not sure how to add velocity to this projectile once its stopped. Any Ideas?

Thank you in advance!

Hey there @Mendez5721! You can set the velocity 2 different ways here, local space or world space:

image

Hi there! Thanks for responding.

I guess I just dont understand which one to apply to my project, nor how to actually apply that. I was messing around a bit with different velocities and the 2 nodes as well. If I set the world velocity, the reused projectile will just spawn in the same space the last projectile hit. I guess Im not sure how to make it start from one location lets say, muzzle tip, and then fire across till it collides again and then goes into the pool again.

Thank you for the help!

My recommendation would be to move the projectile to the muzzle location using set location and rotation, then to just set the velocity you need:

After the collision, you’d just set the velocity to 0 and move it out of the play area to your pool zone.

3 Likes

Here’s some insights from my projectile pooling approach.

The weapon requests the projectile from the pool via BP Interface.
It passes all the needed values via the BPI event/function.

The obj pool queues up a projectile then sets/updates everything in a function.

The minimum that I found when re-using the projectile is the following… in this order.

  • Location: muzzle location…where to teleport too.
  • Velocity: projectile velocity
  • Max range & Muzzle Velocity: these are used to dynamically create a Lifespan time for a custom auto return to pool function… vs destroying the actor.
  • Owner/Instigator: used for dmg application.

Simple lifespan setup


Hope this was helpful.

4 Likes