Announcing Section #2 for Survival Game - Weapons & Interaction

TWeakObjectPtr is a weak pointer to the character. That means it doesn’t hold on to the character in memory. Meaning that if all other pointers are gone except this one, the character will still be deleted from memory. If we were using a regular pointer, it would be kept in memory until this last pointer to the character was removed too.

To get the pointer from a TWeakObjectPtr is done through .Get() like so: ASCharacter MyPawn = PawnInstigator.Get()* This returns the pointer IF it still exists, so make sure you check for nullptr after (if (PawnInstigator != nullptr) { }) before using it.

Hope that helps.

Worth adding that you can also do MyPtr.IsValid() on a Weak Object Pointer to check if it is NULL as well (not nullptr, but NULL!)

Hi thanks for your answer.

I have another question.

I don’t know why when clients shoots each other or shoots to server this function returns false but when server shoots to other returns true… Why this happens?



bool ASWeaponInstant::ShouldDealDamage (AActor* TestActor) const
{
if(TestActor)
{
 if(GetNetMode() != NM_Client ||
TestActor ->Role == ROLE_Authority ||
TestActor->bTearOff)
{
return true;
}
}
return false;
}

It checks if we are allowed to apply damage, which only happens on the server-side OR when the actor is torn off (bTearOff) from the server OR if the actor has authority to make changes, eg. to take damage.

I know that
But when I I test this code on your project everything was Ok server and clients can shoots to each other, but in my project that’s code not working I don’t know what’s wrong in my project, everything is like your project I’m using your project as a learning resources every things is same … I don’t know where I made a mistake.

I have a doubt that how to control the weapon’s force when its bullet hit the actor . i found that when I shoot the bomb, it will move. when i shoot the barrier, it can’t move. I did not find where to set the power of weapon hit. :confused:

i have another question about Skeleton socket . Different rifles have different Skeleton root causing the different result when attached to the same socket. how to sovle this problem except modify the source skeleton file? thank u…

You can rotate the socket after adding it to your skeleton inside the viewer where you added the Socket.

I also can not get “.generated.h” in STypes.h

What’s the problem? the generated.h files don’t need any manual work, the Unreal Header Tool automatically creates these files for you each compile.

In one of the screenshots, I saw there was some nice blood effect going on. How was this done, exactly? Could you share the textures/particles? :smiley: :smiley:

Everything is available in the project files that you can download mate. The blood FX is from the ShooterGame sample, I re-used it for this project too.

Where did or does it create the STypes.h from? I am trying to understand how to create a file like this but the documentation I have read did not make it clear. I followed some examples and they did not work… or at least do not work as of 4.12… maybe something is different

I tried to follow this How to Make Global Functions and Structs? - Programming & Scripting - Epic Developer Community Forums which I thought seemed right and it did not work.

Hello, I am trying to remove the death sequences from the player. I can’t find where some of the functions are being called. UnFreeze(), StartSpectating(), I need to remove these functions but cant seem to figure out where they are even being called from. I know they are in the player controller but I need to just get rid of all of that, so I can handle the death on my own terms but even when I do the spectating messes with it.

Hi. I have the same problem. Did you solve it? Thanks

Regards,