then I dont know what you mean. I added the grabber component in bp_player as component
Then in code like in this post
then I dont know what you mean. I added the grabber component in bp_player as component
Then in code like in this post
void UTriggerComponent::BeginPlay()
{
Super::BeginPlay();
APawn* Player = UGameplayStatics::GetPawn(this, 0);
Grabber = Player->FindComponentByClass<UGrabber>();
}
Thanks @DanM small edit to use GetPlayerPawn
and it work great.
Now just for learning is there a way in C++ without using FindComponentByClass
and UGameplayStatics.GetPlayerPawn
? in @ VeryClumsySloth solution ?. In his solution Grabber always nullptr
So I tried to use new
operator in begin play but then I found this great topic
I will do some reading and try to use NewObject
Like I said earlier, thatâs not possible. Also he grabber is already dynamically allocated and new
ing your bool snât going to change anything about how you get it.
You could make the member on the grabber static. Static member variables are essentially global variables.
This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.
This topic was automatically closed after 30 days. New replies are no longer allowed.