The weapon function can't in the shooting function?


I’m planning to shooting a projectile as bullet from the gun? But that c++ show that breakpoint do anyone know how to fix that?

Well it appears you are trying to cast a pointer of type APlayerController (returned from UGameplayStatics::GetPlayerController) to AWeapon. Since AWeapon extends from AActor and never from APlayerController the cast always fails resulting in the AWeapon* Weapon to point to NULL. Therefore you’re getting a null pointer accessed exception.

You should probably check whether the pointer is != NULL first before using it. Or cast the APlayerController to CSController (assuming their class hierarchy and its class name is appropriate). Without knowing more about your setup it’s impossible to tell where the Weapon actually lives and how to access it properly.

I’m not sure what is actually to do , what is meaning of check the pointer is != NULL, pointer means weapon "AWeapon* Weapon "?

PlayerController posses the Character which “posses”(holds(contains)) Weapon
You need to get possesed Character and from this Character you need to get “current weapon” and if it’s not null execute Shoot on this Weapon

Since you already in characters code then you just need to get “current weapon” and start shooting. In your Weapon class in pullTrigger function you need to check whether this weapon could start shooting and if yes then spawn projectile or whatever you want to spawn

Sorry for my English it’s not my native language

You’re trying to cast the Player Controller to a Weapon, so Weapon is invalid because that’s impossible.

You then immediately dereference a null pointer (because Weapon is null). You need a way to get the proper pointer to the weapon in the first place.