I make it simple and post only an simplified example of what im trying to do.
YourCharacter.cpp
#include Weapon.h
void AYourCharacter::TakePickup()
{
AWeapon* Weapon = Cast<AWeapon>() <------- How to do it correctly?
{
WeaponM4->DoSomething();
}
}
Weapon.cpp
AWeapon::AWeapon
{
WeaponM4 = CreateDefaultsuboject<UStaticMeshComponent>();
}
void AWeapon::WeaponFunction()
{
Do something();
}
So as you can see, i want to call the function from the Weapon.cpp script whenever i the character picks it up.
Any ideas how to do this correctly? Thanks already!