Download

Projectile based on realistic physics destroys itself for no reason...

So as the title says, the blueprint I have here, which is pretty much https://forums.unrealengine.com/showthread.php?47541-Better-Blueprint-Bullets That guys blueprint that I am using as a reference. It seems to destroy itself after a period of time even though the projectile isn’t actually told to do so atleast not in that case.

Some pictures so I can be better understood.

The first picture as you can see is the blueprint, like the one in the link provided, the only real change was setting the velocity from a float variable, to make it a bit easier for me
c4d5b277c3a0f9ebc5530a9195e22b29d0592505.jpeg

The second is what I am experiencing, you can see that it does what it is supposed to with the slowing down and dropping taking place, but then it just gets deleted.
attachment.png

This final picture should be a bit clearer, what I’ve done is stopped the gravity and drag from affecting the projectile, and also slowed it down to 10 m/s as you can see it still only travels a short distance and stops, and I can’t figure out why

So hopefully from those pictures you can get an understanding on what I’m trying to do here. I have also asked the original guy who created the blueprint and he suggested I post here instead.

I suggest printing the vector length every tick…

And letting it run until it stops printing that length. If it keeps printing to screen, you bullet is still in the world and doing its thing.

So I’ve done what you suggested and it prints 1000 (which is the 10 meters a second) each tick before any event even happens, it stops at the exact time the projectile stops, sometimes the number is slightly higher and slightly lower than 1000 but by a miniscule amount, something like 0.0006.

Hello,
Can it be garbage collected ? Try to add bullet in an array on spawn to see if bullet disappears too.
And : Does it stop always at the same time ? If yes knowing this time can help debugging.

It always stops after the same length, although depending on the initial velocity I set that length could be longer or shorter, as for the array, I will try that and edit back, although I do notice it does disappear from the scene outliner.

Ok, print a string after the destroy actor that should trigger on hit, see if it is triggered by that for some reason.

Also, do you have other functions in the Blueprint? Does it do anything else?

If you zip it up and place a download link somewhere I’ll take a look tonight when I get home.

So I added the print string, both before and after the destroy actor node in the trigger on hit section, it doesn’t fire off at all…

Here is the download link https://www.dropbox.com/s/k6t2pxclwo11wo3/realistic%20bullets.zip?dl=0, what I did to reduce the file size was remove the starter content, so if you rip that out of a new fps template and place it in, it should work fine…

Just got a look and your set velocity in apply gravity is not linked to your set actor location. When it is linked the gravity effect begins from start (and it begins underground but it must be some spawn location projectile setting).

In the beginning of the function he sets the actor location to something new… calculated on the current velocity… the current velocity is then updated with new gravity effect and drag. Which is then used to update the location of the actor at the beginning of the next tick.

And the gravity is merely a negative value of -980 which is 9.8 m/s… the force of gravity on earth. Gravity is not a location, it is merely something that is added to the current velocity. The current velocity is also not a location, it is how fast the object is moving in 3 dimensions. Locations are stored in a Vector3… but a Vector3 can be used for others things besides location.

The main reason I unlinked them is to see if the projectile still deleted itself only travelling straight without anything affecting it, if you connect it back up and set the speed a bit quicker and shoot towards the air somewhere you will see it still disappears.

I have found the problem…

Under Defaults you have set the “initial lifespan” to 3 seconds…

Ahahah such a simple thing, thanks a bunch mate I wasn’t even aware of such a thing.