Thruster can't be created

Why am I getting this error?

“Thuster can’t be created”


function ShoppingCartScript:Init()
    self.thruster = self:GetEntity():CreateThruster()

Script is applied to a Mesh Entity, with physicsEnabled=true.

What could be the reason for this error?

1 Like

I figured this out myself: When you have an entity with a script that creates a thruster in the Init event, and you repeatedly test your script by activating and deactivating the ‘simulate’ option on the entity, then after a while you get this error.

I’m guessing that when deactivating the simulate option, the created thrusters aren’t removed from the entity, and each time the simulation option is activated, the Init funcion is called and new thruster is created. After a while, a maximum number of thrusters is reached.

So, is this a bug or a feature?
In what script event/function should once place the code to remove the thrusters, so that this code is called when the simute option is deactivated?


I’m not using simulate option and I still start to get that after some time (I’m using preview mode instead).

Once it starts to hit, I can’t work with thrusters anymore until some other time (was not able to determine how long’s that exactly, but usually next day it’s fine).

I added code like this

function MyScript:OnDestroy()

in hopes that it would allow me to avoid this problem, I’d see how it goes from here, but honestly that looks like a bug on a Crayta side, I don’t understand why it cannot clean them itself.

1 Like

After I made that workaround, I don’t have the previous problem, when thrusters would just stop creating forever, but now I noticed that right after “Thruster can’t be created” during preview, when I go back from preview the whole server crashes (start countdown till 60 seconds and restarts).

1 Like

I use thrusters to power rockets fired from my ship because using :SetPosition(x) avoids physics collisions. While developing this I was experiencing strange server behaviour similar to that described here.

I even tried putting the thruster client side; updating it on OnClientTick() after property changes, but the server physics always overrides the client physics and it just drops to the ground.

After finding this article and creating a script which uses CreateThruster in Init() and DestroyThruster in OnDestroy(), I was then able to create a bunch of good looking rockets which work as expected! Yay, or so I thought, it worked for a while, after a number of times using thrusters the server consistently crashes again even if I use destroy thrusters properly.

So, is there a thruster limit? How would I, or can I, set them up on client side to override server physics?

If I should not be using thrusters for shooting multiple rockets from my ship during a game, what else should I be using?

There is a thruster limit, and thrusters have been notoriously bugged for years now.

Destroying them manually has typically been the solution. Is it possible you’re not destroying all of them? Maybe creating 3 but only holding a reference to the last one spawned, for example

1 Like

The prototype projectile object on the ship is the one I use to clone other rockets from, and is also destroyed. After several iterations of code changes I put thruster:SetAutoDestroy(3) in the projectiles Init function in the hope it would ensure all thrusters are destroyed after 3 seconds, no matter what. But it still bugs out after using lots. Should I be setting the variable to nil in OnDestroy() maybe?

So, I gave up on thrusters because of the limitation and the bugs. I have opted instead to use PlayTimeline on the projectile entity for the path. It kind of works. It seems to reliably fire only trigger events though, and straight up collisions don’t work, making me think playTimeline also avoids physics updates? The rocket does impact physical objects in the world and can send them flying off but only works with triggers when calling my code.

Is there a better or different way to code for rocket and collisions?

Update: I can use :AddImpulse(v) and it seems to work well for my rockets

if self.useThruster then
elseif self.useVelocity then
elseif self.useImpulse then
			duration or 1,
			self:GetEntity():GetPosition() + forceVector