This forum is locked and will eventually go offline. If you have feedback to share you can find us in our Discord channel "MythoLogic Interactive" https://discord.gg/nECKnbT7gk

Forum rules

NullReferenceException when using IGame.CreateObject() in ObjectDamageCallback

Here you can find all solved gameplay problems and bugs (beginning from Pre-Alpha 1.8.8).
Forum rules
By using the forum you agree to the following rules. For this forum you also need to follow these additional rules.
Locked
NearHuscarl
Superfighter
Superfighter
Posts: 97
Joined: Thu Feb 07, 2019 4:36 am

NullReferenceException when using IGame.CreateObject() in ObjectDamageCallback

Post by NearHuscarl » Mon Mar 02, 2020 3:26 pm

Image

This happens when I Remove() and recreate the same IObject in the same frame. Also, said object is the target object of the WeldJoint and AlterCollisionTile

Here is the minimal sample code

Code: Select all

public void OnStartup()
{
   Events.ObjectDamageCallback.Start((o, a) => Game.CreateObject("BgRailing00E"));
}
1 x
Image

User avatar
Gurt
Lead Programmer
Lead Programmer
Posts: 1887
Joined: Sun Feb 28, 2016 3:22 pm
Title: Lead programmer
Started SFD: Made it!
Location: Sweden
Gender:
Age: 36

Post by Gurt » Sat Mar 21, 2020 4:24 pm

Fixed after v.1.3.4.
Caused by the fact that impact related damage is caused in the middle of the update, locking the box2D world causing creation of tiles to be unavailable. Fixed by quining up any impact related damage to after the box2D step is done.
0 x
Gurt

Locked