Page MenuHomeFeedback Tracker

TurretComponent::SetAimingRotation clamp bug
Closed, ResolvedPublic

Description

When attempting to set angles beyond +-90 degrees via TurretComponent::SetAimingRotation it clamps back to +-90. This makes it impossible to look "back" seen relative to the forward vector of the turret entity.

The expected behavior from below is that the turret is facing slightly backward to the left

TurretComponent turret = ...;
turret.SetAimingRotation("-130 10 0" * Math.DEG2RAD);

However, right now after executing it, the getter only returns -90, and visually it's the same. Why is there a value limit on this?

"m_vAimingRotation": [ -90.0, 10.0, 0.0]

This problem might have been introduced between 0.9.7 and 0.9.8.50.

Details

Severity
Major
Resolution
Open
Reproducibility
Always
Operating System
Windows 10 x64
Category
General
Steps To Reproduce
class TestMoveTurretComponentClass : ScriptComponentClass
{
}

class TestMoveTurretComponent : ScriptComponent
{

	//------------------------------------------------------------------------------------------------
	override protected event void OnPostInit(IEntity owner)
	{
		Print("TestMoveTurretComponent::OnPostInit()");
		SetEventMask(owner, EntityEvent.INIT);
	}
	
	//------------------------------------------------------------------------------------------------
	override protected void EOnInit(IEntity owner)
	{
		Print("TestMoveTurretComponent::EOnInit()");
		
		SlotManagerComponent slotManager = SlotManagerComponent.Cast(owner.FindComponent(SlotManagerComponent));
		array<EntitySlotInfo> outSlotInfos();
		slotManager.GetSlotInfos(outSlotInfos);

		foreach (EntitySlotInfo slotInfo : outSlotInfos)
		{
			IEntity slotEntity = slotInfo.GetAttachedEntity();
			if (!slotEntity)
				continue;
			
			TurretControllerComponent turretController = TurretControllerComponent.Cast(slotEntity.FindComponent(TurretControllerComponent));
			if (!turretController)
				continue;

			turretController.SetAimingAngles(120.0 * Math.DEG2RAD, 15.0 * Math.DEG2RAD);
		}
	}
}

Put this component onto your {B47110AA1A806556}Prefabs/Vehicles/Wheeled/BTR70/BTR70_FIA.et and see how it only does 90 degrees.

Event Timeline

Arkensor created this task.May 2 2023, 1:02 PM
Arkensor edited Steps To Reproduce. (Show Details)May 2 2023, 5:06 PM
Arkensor changed Operating System from Windows 7 to Windows 10 x64.
Geez changed the task status from New to Assigned.May 3 2023, 10:54 AM
Geez closed this task as Resolved.May 23 2023, 12:45 PM
Geez claimed this task.
Geez added a subscriber: Geez.

Hello Arkensor.
According to the devs this can't be resolved due to how compartments and weapon manager are initialized. If you want to set the aiming angles you should delay it by one frame. Using CallLater should be enough.