Page MenuHomeFeedback Tracker

HitZoneContainerComponent's data availability depends on the component name?!?
Assigned, NormalPublic

Description

I was experiencing an issue where I added a component to my vehicle that handles something with the hit zones and was later renamed. I just spend 2 hours trying to find out why my script is not working anymore and it turns out that DEPENDING ON THE COMPONENT NAME during post init the hit zones are available or not.

If it is called ADebugHitZonesComponent and added to a vehicle then it does not work because "A" comes before the inherited hitzonecontainer name and thus is loaded first?!? Even though one would assume that on PostInit all other components are initialized right? Well, apparently not so. And I need the data on post init.

class ADebugHitZonesComponentClass : ScriptComponentClass
{
}

class ADebugHitZonesComponent : ScriptComponent
{
	override event void OnPostInit(IEntity owner)
	{
		HitZoneContainerComponent hitZoneContainer = HitZoneContainerComponent.Cast(owner.FindComponent(HitZoneContainerComponent));
		Print(hitZoneContainer);
		
		if(!hitZoneContainer) return;
		
		array<HitZone> outHitZones();
		Print("nHitzones: " + hitZoneContainer.GetAllHitZones(outHitZones));
	}
}

SCRIPT : HitZoneContainerComponent hitZoneContainer = SCR_VehicleDamageManagerComponent<0x000001E22BAAD470>
SCRIPT : nHitzones: 0

The funny part is that if I call the component ZDebugHitZonesComponent I make sure it's loaded last, I guess? Well, it works there ...

SCRIPT : HitZoneContainerComponent hitZoneContainer = SCR_VehicleDamageManagerComponent<0x000001E22BAAC1E0>
SCRIPT : nHitzones: 14

It gets the correct instance of the component, I checked, but I feel like on the engine side the hit zones are initialized only after post init. If I delay the call with a thread to the next frame or use an event called later it all works.

Details

Severity
Major
Resolution
Open
Reproducibility
Always
Operating System
Windows 10 x64
Category
General

Event Timeline

Arkensor created this task.Aug 8 2022, 11:10 PM
Geez changed the task status from New to Assigned.Aug 30 2022, 1:30 PM