It Works if i open a new project , but it doesn’t if i try to add it to my actual project. i think there is a problem with my actual project, maybe a file is corrupted.
What do you mean exactly by “it doesn’t work”, please be precise.
If the variable is set to null between the end of the constructor and the beginplay, I’ve seen it a lot, it can come from old blueprint serialized data that set your variable to null. You can try to change the variable name to fix this.
You are missing a second line that is required to attach your mesh to the component. You need to tell your mesh where it is attached to, otherwise it just exists within the confines of the class.
SetupAttachment is specific to SceneComponent and is useful for the hierarchy of transforms, but it is not mandatory. By default components will be children of the root component