I have created a static mesh with a hologram material on my FP_Gun’s muzzle socket to make a laser pointer for my character’s gun. So far everything is cool, but I want to make it only visible when I aim kinda like resident evil. Problem is, the only way I managed to do this was to cast to my BP_Character and check if he is aiming
, it works but also affect my NPCs, which is obviously not cool. Is there a different way I could make this work in order to have my LaserSight only visible when I aim and the NPCs’ always visible, except when IsDead is checked?
Can you access your gun from a character? I.e. how your gun was spawned? If it’s accessible you can just toggle on\off your laser sight from the character when he is aiming.
UPROPERTY of ActorComponent type is usually visible as a component in blueprint. UPROPERTY(BlueprintReadOnly) or UPROPERTY(BlueprintReadWrite) usually visible inside blueprints. Also you can create a UFUNCTION(BlueprintCallable) AGunActor* GetGun(); which will return your gun reference to the blueprint.
That’s what I tried but can’t seem to cast to BP_Gun properly in my BP_Character because I can’ get the reference to the gun (or I don’t do it the right way). My Gun is spawned on BeginPlay in C++ (my game is an hybrid C++/BP) maybe if I get the reference there I could make it visible in my AI.cpp and make the toggle in my Player.cpp. My bFocus bool is created in my Character.cpp.
I had one but weirdly in the camera category. I managed to make everything work by creating a function LaserSightVisibility and calling it on Tick. Then, because my NPCs are always on IsAiming by default, I just had to set it to false on my KillAI function.
Thanks for the help!!