Setting a variable to reference mesh causes variable to override it?

Heya guys!

I have a variable like so:


UPROPERTY(BlueprintReadWrite)
	class USkeletalMeshComponent* ItemSocketMesh;

This is so depending on what you are (Human, or Player which is a Human) the variable will either be Mesh or Arms.

So… when I do this:


ItemSocketMesh = Mesh;

The component is replaced with ItemSocketMesh… in other words, within the blueprint, instead of “Mesh”, we get “ItemSocketMesh”.

However on my player class I have an Arms mesh:


UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Arms)
	class USkeletalMeshComponent* Arms;


It works as intended.

Any reason why this is? I’m stuck :cry:

Are you inheriting from ACharacter class?

If so, it already has a variable called ‘Mesh’, which might be the cause of your problems - since it’s the updated mesh that forms the main body of the character. Try using a different variable name.

Yes, and this is on purpose… isn’t the mesh variable meant to be used?

Basically the mesh in my human class is what’s considered the body. In the human class, the variable ItemSocketMesh is set to the Mesh (body), which means the game will connect weapons and stuff to the Mesh.

However in my player class, (which is inherited from human) there’s still the mesh class, also the body. However in this new class we have another mesh added: the arms. This is to allow the player to rotate arms with the camera. In other words, the ItemSocketMesh is set to Arms.

And for the player, everything works:
player.png

Yaaasss. However, whenever I set ItemSocketMesh to Mesh, this happens:
player.png

What it’s supposed to do is not change to ItemSocketMesh, just like player does. When I do this to the Arms, it doesn’t do this…
I am never recreating mesh, because it’s created in the character class, I’m just referencing it.

I hate bumping, but my project is on freeze until I figure it out lol X)