Spawning > 3 copies of a prefab with a Physics Collider crashes Application

Upon trying to run the following code, spawning a prefab that contained nothing more than a blank plane and a Physics Collider (Static or Dynamic), I was met with an error:

for (let i: number = 0; i < 10; i++) {
  const originX = Math.random() * 3
  const originY = Math.random() * 3
  const originZ = Math.random() * 3
  const newPlane = world.createEntity(prefab)
  world.setPosition(newPlane, originX, originY, originZ)
}

Returns the following Error:
▼ Uncaught RuntimeError: null function or function signature mismatch
at syncWorldToPhysics(ecs_world_t*, PhysicsContext*) 00413022:wasm-function[106]:0x7627
at stepPhysics(ecs_world_t*, PhysicsContext*, float) 00413022:wasm-function[112]:0x887d
at c8EmAsm_progressWorld 00413022:wasm-function[28]:0x21a2
at Object. runtime.js
at k runtime.js
at F runtime.js
at Object.tick runtime.js
at r runtime.js
at (anonymous) runtime.js
at e runtime.js

However, if I instead take the collider off of the prefab, and create it when I spawn the entity as so:
for (let i: number = 0; i < 10; i++) {
const originX = Math.random() * 3
const originY = Math.random() * 3
const originZ = Math.random() * 3
const newPlane = world.createEntity(prefab)
world.setPosition(newPlane, originX, originY, originZ)
ecs.Collider.set(world, newPlane, {
shape: ecs.ColliderShape.Box,
width: 1,
height: 1,
depth: 0.1,
mass: 1,
friction: 0.5,
restitution: 0.5,
linearDamping: 0,
angularDamping: 0,
rollingFriction: 0.1,
spinningFriction: 0.1,
})
}

I no longer get an error.

I’m guessing this is a bug, so I’m making it known :+1:

Oh I forgot to mention that if the for loop runs for 1, 2, or 3 iterations the error does not appear, it is only after i = 4 that this happens.
It also does not have anything to do with all of these entities being spawned on the same frame, as I tried to space them out with a timeout and was met with the same result.

I’ll take a look at this now.

1 Like