Skip to content

Non-static objects created by createObject are misplaced after being re-streamed #4706

@rxyyy

Description

@rxyyy

Describe the bug

Objects with physics / breakable objects created with createObject are misplaced when streamed out and back in again after being pushed / broken. I tested this with model IDs 2968 (cm_box) and 1344 (CJ_Dumpster2).

If the box is pushed but not broken, when re-streamed, its position would persist but its rotation would reset to its initial rotation. If the box is broken, when re-streamed, it would respawn at its last position with its rotation reset to its initial rotation.

If the dumpster is pushed, when re-streamed, its position would persist but its rotation would reset to its initial rotation just like the box. The dumpster cannot be broken, so the second box bug doesn't happen here.

Additionally, objects created from createObject seem to have a much higher streaming distance compared to the same models found around the map in vanilla SA, and no documented way to make them respawn at their initial position once they're streamed out.

In general, there seems to be no way to create objects that behave the same way as vanilla SA map objects (respawn at original position once streamed out).

Steps to reproduce

  1. Create any breakable object or an object with physics, see the example code below.
  2. Push or break the object as described in the issue.
  3. Stream out the object, then stream it back in.
  4. Observe that the rotation resets to the object's original rotation parameters passed to createObject.

Version

Client: Multi Theft Auto v1.6-release-23869
Server: MTA:SA Server v1.6-release-23869

Additional context

Here's an example resource to spawn the two objects. Teleport to { x = -2757.172, y = 180.153, z = 6.928 } to see them.

	local objects = {
		{
			modelID = 1344, -- CJ_Dumpster2
			positionX = -2754.2,
			positionY = 187.5,
			positionZ = 6.8,
			rotationX = 0.04,
			rotationY = 0.6,
			rotationZ = 268.0,
		},
		{
			modelID = 2968, -- cm_box
			positionX = -2754.7,
			positionY = 189.0,
			positionZ = 6.31,
			rotationY = 358.0,
			rotationZ = 338.0,
		},
	}

	for _, object in ipairs(objects) do
		createObject(
			object.modelID,
			object.positionX,
			object.positionY,
			object.positionZ,
			object.rotationX or 0.0,
			object.rotationY or 0.0,
			object.rotationZ or 0.0,
			false)
	end

Relevant log output

Security Policy

  • I have read and understood the Security Policy and this issue is not security related.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions