ENGINE CRASHES sometimes with my actor class: "ACCESS VIOLATION"

After testing both server and client shooting rockets for about five minutes each I haven’t seen this yet, but I’ll keep trying to reproduce it periodically. I would also like to add that, in the project you sent me, the projectiles do not move after spawn. They remain in place for about three seconds before being destroyed. If the projectiles are destroyed both after a set amount of time as well as after impacting with an object/surface, it is possible that in rare cases the destroy function is being called twice.

I would also like to add that, in the project you sent me, the projectiles do not move after spawn

Try opening the Proj_Rocket blueprint in the path Blueprint->Projectiles and changing the “Speed” to about 800.
Also make sure the “Is Explosive” boolean is checked.
Also, in the Effects panel, make sure the Explosion Template is set to Missile_ExplosionFX

If the projectiles are destroyed both after a set amount of time as well as after impacting with an object/surface, it is possible that in rare cases the destroy function is being called twice.

If you see in the DestroyProjectile() function inside Projectile.cpp I make only the Server destroy the projectile. This destruction is then replicated to all Clients.
It shouldn’t crash!!

I haven’t seen this yet, but I’ll keep trying to reproduce it periodically

Thanks, it’s really important!

For now, just test this on the Client because, in 90% of the cases, the Server always gets things right.

Let me know!

Any news?

Hey -

I was finally able to get the crash to occur after deleting the project and unzipping it again. By removing the ‘else’ from DestroyProjectile() but leaving in the debug message, I found that the DestoryProjectile() function is being called twice when a rocket is destroyed. The crash is occurring on the second call to the function which seems to indicate that when the call is made the second time the object has already been destroyed, and looking for the movement component or comparing the explosion variables is being done on an object that no longer exists. Ensuring that the function is only called once per rocket should prevent the crash from occurring.

Cheers

I would say it’s due to this Timer in the BeginPlay() function

void AProjectile::BeginPlay()
{
	/* TRIGGER TIMER FOR THE PROJECTILE LIFETIME EXPLOSION */
	FTimerDelegate ExplosionDelegate = FTimerDelegate::CreateLambda([=]()
	{			
		
		this->DestroyProjectile();
	});

	if (OwnerWeapon)	
		GetWorldTimerManager().SetTimer(ExplosionTimer, ExplosionDelegate, OwnerWeapon->ProjectileConfig.ProjectileLifeTime, false);
	
}

Here I’m saying: “destroy the projectile after x seconds”, where ‘x’ is the LifeTime value of the Projectile.

The most problematic thing here is that this crash is not consistent. It’s difficult to understand what causes that to happen.