Casting to USkinnedMeshComponent works differently for Static/Skeletal meshes
I Have a superclass Equippable which requires a USkinnedMeshComponent in order to function. I would like to be able use either UStaticMeshComponent or USkeletalMeshComponent in my subclasses, since different types of objects have different animation requirements.
However, I'm having some trouble regarding casting. I was originally just trying to cast the root component to a skinned mesh component, but was unsuccessful, so I'm now simply setting a USkinnedMeshComponent* in the constructor of each subclass. To do that I'm using the following function:
Which works fine... if NewRootMesh is a USkeletalMeshComponent. If it is a UStaticMeshComponent, however, I need to use this function:
In the latter example, I must cast NewRootMesh using that syntax. If I use Cast(NewRootMesh) in this case, it returns null.
I read somewhere (in presumably old documentation that I am now unable to find) that both of these classes extended the skinned mesh component, which is why I'm attempting to do this... but I'm now realizing that according to the latest docs, UStaticMeshComponent actually does not extend USkinnedMeshComponent. This would explain the casting issue. It does not explain, however, why I'm still able to cast my static mesh to a skinned mesh using this syntax. It seems to work just fine. Can anyone explain to me why this would be the case?
asked Oct 17 '16 at 05:56 PM in C++ Programming
Follow this question
Once you sign in you will be able to subscribe for any updates here