Where is the aim/shoot logic in LYRA?

I want to see how epic implemented aim logic for the lyra project, but I can’t find where is the logic for the aim and shooting (specifically for the rifle) that is responsible for shooting the bullet exactly where the aim is

Can someone help me please?

Firing mechanic seems to be in GCN_Weapon_Rifle_Fire => which triggers B_Weapon => Fire

In the animInstance ABP_Mannequin_Base you have two parameters

Aiming Data (“category”)
AimPitch (float)
AimYaw (float)

it’s used in functions “Update Aiming Data” & “Set Root Yaw Offset”

As for the control mechanic (inc. aiming) there are a couple of layers of abstraction through data assets and abilities.

1 Like

Thank ypu for the reply,

I want to see how epic makes the bullet for the rifle go to the crosshair, but i can’t see where is that logic. Maybe i’m just stupid :slight_smile:

It’s hidden in C++ somewhere, related to Start Ranged Weapon Targeting found in GA_Weapon_Fire I believe.

It’s probably just a trace from the muzzle to an end point. An end point gotten by first doing a trace from the camera to a forward vector, far enough to hit wherever you might have a target. That will send a bullet to the crosshair.

1 Like

Hi again Astaraa! you seem to know the most about Lyra. I am having trouble with line tracing. it always points to the world spawn location or at best straight along x or y or z axis. I cant get the line trace to simply go where i am aiming. do you know how to fix this in Lyra? Thanks!!

Hi :slight_smile: Can you show what you’re doing?

1 Like

Please comment out there.

LyraGameplayAbility_RangedWeapon.cpp

void ULyraGameplayAbility_RangedWeapon::OnTargetDataReadyCallback(const FGameplayAbilityTargetDataHandle& InData, FGameplayTag ApplicationTag)


.......
		if (bIsTargetDataValid && CommitAbility(CurrentSpecHandle, CurrentActorInfo, CurrentActivationInfo))
		{
			// We fired the weapon, add spread
			ULyraRangedWeaponInstance* WeaponData = GetWeaponInstance();
			check(WeaponData);
			WeaponData->AddSpread();  // <--Comment Out there!!

			// Let the blueprint do stuff like apply effects to the targets
			OnRangedWeaponTargetDataReady(LocalTargetDataHandle);
		}
		else
		{
			UE_LOG(LogLyraAbilitySystem, Warning, TEXT("Weapon ability %s failed to commit (bIsTargetDataValid=%d)"), *GetPathName(), bIsTargetDataValid ? 1 : 0);
			K2_EndAbility();
		}
........