Hi Zark,
I have been trying to do this myself but seems like I am stuck big time. Sorry for being such a pain. I did what you told and the arrow spawns only for the first time and after that it never spawns. So i changed it like this
void ABow_ArrowCharacter::Release()
{
USkeletalMeshComponent* UseMesh = GetMesh();
float DeltaTime = 100;
if (ChargeTime != 0)
{
float ChargePercent = FMath::Clamp(ChargeTime, 0.0f, MaxChargeTime) / MaxChargeTime;
float Speed = ChargePercent*MaxArrowSpeed;
GEngine->AddOnScreenDebugMessage(-1, 2.f, FColor::Black, TEXT("Draw"));
}
if (ProjectileClass != NULL)
{
FVector CameraLoc;
FRotator CameraRot;
GetActorEyesViewPoint(CameraLoc, CameraRot);
/*FVector const MuzzleLocation = CameraLoc + FTransform(CameraRot).TransformVector(GunOffset);*/
const FVector SocketLocation = UseMesh->GetSocketLocation("ArrowSocket");
//const FRotator SocketRotation = UseMesh->GetSocketRotation("ArrowSocket");
FRotator MuzzleRotation = CameraRot;
MuzzleRotation.Pitch += 10.0f;
UWorld* const World = GetWorld();
if (World)
{
FActorSpawnParameters SpawnParams;
SpawnParams.Owner = this;
SpawnParams.Instigator = Instigator;
AProjectile_Arrow* const Projectile = World->SpawnActor<AProjectile_Arrow>(ProjectileClass, SocketLocation, MuzzleRotation, SpawnParams);
if (Projectile)
{
FVector const LaunchDir = MuzzleRotation.Vector();
Projectile->InitVelocity(LaunchDir);
Projectile->GetProjectileMovementComponent();
}
}
}
ChargeTime = 0;
bHold = false;
if (bHold)
{
ChargeTime += DeltaTime;
}
}
I have added debug message in the IF statement but seems like it is not working. Am I missing something?
thanks,
Spark