I am having two class, one is my Character Class and another is a Axe class with the character is holding
i set my character class to spawn the Axe.
It is done in BeginPlay();
the code is very simple just like this
Axe = GetWorld()->SpawnActor(FVector::ZeroVector, FRotator::ZeroRotator);
if (nullptr != Axe)
{
Axe->AttachToComponent(GetMesh(), FAttachmentTransformRules::SnapToTargetIncludingScale, BackSocket);
}
So, In my Axe class, i want a Throw function to work, and when it is called, i want to detach it from my character. i did the code like this
void AIFAxe::Throw()
{
DetachFromActor(FDetachmentTransformRules::KeepRelativeTransform);
ProjectileMovement->MaxSpeed = 4500.0f;
ProjectileMovement->InitialSpeed = 3000.0f;
}
But as soon as i call the function. the engine crashes. what could be the problem?
Thanks and have a good day