I have implemented impact particle effect and muzzle flash but the problem is with camera movement and aim location. I was able to move left and right and shoot but when i move up and down the camera moves but the aim location (i.e debug line) goes only in horizontal left and right but not up and down.When I move the mouse along Y axis the camera moves but the player was unable to shoot up and down.
This is my fire function code
void AShooterCharacter::Fire()
{
/*Attach muzzleflash particle effect to Muzzle_01 socket of Gun
GetMesh() is to get the parent of the gun mesh i.e wraith character mesh which has gun by default*/
UGameplayStatics::SpawnEmitterAttached(MuzzleFlash, GetMesh(), TEXT("Muzzle_01"));
/*Get the starting location and rotation of the Line trace which is the Muzzle_)1 socket location
in the gun attached to wraith mesh*/
FVector Start = GetMesh()->GetSocketLocation(TEXT("Muzzle_01"));
/*The rotation is important to make the line trace to go at proper direction at all rotation*/
FRotator StartRotation = GetMesh()->GetSocketRotation(TEXT("Muzzle_01"));
/*The end location of line trace is start added with the rotation Vector() gives forward vector in any
rotation multiplied by range(100.0f)*/
FVector End = Start + ( StartRotation.Vector()* Range);
//Debug line
DrawDebugLine(GetWorld(), Start, End, FColor::Green, false, 1.0f, 0, 1.0f);
FHitResult HitResult;
FCollisionQueryParams params;
params.AddIgnoredActor(this->GetOwner());
bool DidHit = GetWorld()->LineTraceSingleByChannel(HitResult, Start, End, ECollisionChannel::ECC_Visibility, params);
if (DidHit)
{
UStaticMeshComponent* HitMesh = Cast<UStaticMeshComponent>(HitResult.GetActor()->GetRootComponent());
if (HitMesh && HitResult.GetActor()->IsRootComponentMovable())
{
UGameplayStatics::SpawnEmitterAtLocation(GetWorld(),ImpactEffect,HitResult.Location);
HitMesh->AddImpulse(FVector(1, 0, 0) * ImpulseAmount);
}
}
}
And I used this method for character animation blueprint. Is this a problem for not able to aim up and down?