It has a velocity, simulation is set to enabled, it’s attached to the static mesh, I don’t know why it isn’t moving.
I am trying to implement object pooling to reduce the lag caused by spawning projectiles, and it’s mostly working, except when projectiles hit a wall, they stop (like they’re supposed to) but don’t start moving again when they’re brought back from the pool. Clearly they are keeping some data from when they hit the wall but I can’t find what it is so I can’t reset it.
So when a projectile comes to a stop, (if not set to bounce) simulation also stops, this is part of the base UprojectileMovementComponent base cause of HandleImpact thus nothing will happen on tick.
What you can do is to resimulate each time a projectile is activated from pool, it should work.
Let me know
Ok, How does one resimulate? I just don’t know how to do that.
just as example if you want to freeze projetile in mid air. On the pause moment if you define some new simulation/physics variables it will continue with them.
So you can just set simulation enabled true, when a new one activated from pool.
void UProjectileMovementComponent::StopSimulating(const FHitResult& HitResult)
{
Velocity = FVector::ZeroVector;
PendingForce = FVector::ZeroVector;
PendingForceThisUpdate = FVector::ZeroVector;
UpdateComponentVelocity();
SetUpdatedComponent(NULL);
OnProjectileStop.Broadcast(HitResult);
}
Ok nice, couple of more debug questions. I see that you giving a new velocity which is good.
Is anything running on projectile stop event? Like something spawning etc that modifies projectile base?
Can you try with bounce enabled? Like OnBounce bring back to pool and spawn again.
Also assuming its not on the same tick? When you spawn from pool?
So we can pinpoint problem space.
Sorry, What are you assuming is not on the same tick as spawning from pool?
I don’t have anything on On Projectile Stop and setting Bounce Enabled to true doesn’t appear to have changed anything.
This appears to have fixed it! Thank you so much! It would have been really embarrassing to go back to my team and say “in the two days I’ve spent working on this, I broke projectiles in our shooter”
its ok it happens, thats why we test things
Covered this a while back
Nice one!
I am taking a different approach and a data driven design on my weapons system. Have unified weapon structs and weaponData structs defining everything from, shooting type (projectile, hitscan) to penetration values, from speed to kickback ratios even spray patterns.
I use a unified GAS ability that just executes shooting doesn’t cares what is it, just talks with necessary systems if can shoot, has to wait etc. cause all guns have different activation mechanics, burst to modifiers, overheat to gatling speed up.
Have custom projectile since I run ability base on server basically does the same thing.
Other things like audio decals etc. agnostic and independent from the projectile it just looks for a hit if there is and what is hit and do their own thing. I really like how GAS child abilities can create logical containers and its easy to use. It’s experimental but I think its pretty nice design. What you think?
a simple weapon like shotgun is like this and is all controlled by data
Same other than GAS. It’s too heavy for my needs. I’m doing a bit of server-side anti-cheat and the project is for 64-100 player open world (8km^2 +), 30-50K interactive actors.
Weapons system is 100% data configured using encapsulated structs for varying aspects of the weapons usage. [base config, appearance (mesh, materials, skins settings etc), ballistics, animation, recoil, attachments etc]
Data is stored in respective DT’s and the structs are set at runtime during weapon creation.
I use actor components for specific weapon mechanics. These are added at runtime per proxy based on their config… single, burst, auto firing etc.
For projectiles I have a dedicated child class per proxy. Each handles proxy specific behavior. Hits and A/V FX are handled by the proxies projectile pool. This reduces the projectile class load so I can get it back to the pool faster.
My entire project is built around split code encapsulated logic. Autonomous code, Sim code, Authority code.
Thanks for sharing! Yeah this pool data maybe i do also like that rather than passing all the time. Didn’t have any problems but why not.