Derived Actor class' SetActorRelativeLocation not changing weapon's location

Hello everyone,

I have made a few weapon class actors. All of them deriving from ABaseWeapon.

When spawning the weapons all of the actors whose parent class is ABaseWeapon, will have their locations changed.

However, weapon actors spawned using a derived class of ABaseWeapon such as ABladeWeapon. I have not been able to set its relative location upon spawning.

I have checked my BeginPlay functions and have included the Super::BeginPlay as part of the function. I am at a lost here, what is it that I’m overlooking?

image
Above is the base class implementation.


And this here is the derived version.


This is where and how I spawn those weapon actors onto the character. I reference the weapons by class reference before looping through them. Spawning them before attaching them to the component that spawns the weapon.

(Edit: Resolved! I am dumb… The issue was simply an ‘order of execution’ problem. Nothing to strictly to do with Unreal. As I was spawning the weapon actors, I had forgotten I had a debug mode, where it’d allow me to manually adjust weapon offset location relative to player at runtime.

In my third image, the SpawnCharacterWeapons(). I was spawning and setting the world location via the component. Then it goes into each weapons’ BeginPlay() function and does the SetActorRelativeLocation(FVector location).

ONLY TO BE ORVERWRITTEN by TempWeapon->AttachToComponent(). Meaning, it set it all back to the parent component’s location in world space and reset its relative location to zero.)

You will need to post more information, otherwise people won’t be able to help you. Probably won’t even want to deal with it.
Show the code that changes the actor location, show how you gather references to those actors, etc…

Thank you for that.

I’ve made some edits and hopefully it’s easier to understand. I’ll be sure to keep this in mind for the future.

(Edit: Resolved! I am dumb… The issue was simply an ‘order of execution’ problem. Nothing to strictly to do with Unreal. As I was spawning the weapon actors, I had forgotten I had a debug mode, where it’d allow me to manually adjust weapon offset location relative to player at runtime.

In my third image, the SpawnCharacterWeapons(). I was spawning and setting the world location via the component. Then it goes into each weapons’ BeginPlay() function and does the SetActorRelativeLocation(FVector location).

ONLY TO BE OVERWRITTEN by TempWeapon->AttachToComponent(). Meaning, it set it all back to the parent component’s location in world space and reset its relative location to zero.)