Page 1 of 1

how to change attached skin? [C#]

Posted: Wed Mar 07, 2018 7:52 am
by amtp
Hi all,
I will be glad to any help on my question. I need to change the skin of clothing from my character,
I'm trying to do it like this:

Code: Select all

CharacterAttachment chrHair = _character.GetAttachment("shois"); IAttachmentObject pSkinAttachment = new IAttachmentObject(); ISkin newSkin = Global.gEnv.pCharacterManager.LoadModelSKIN("Objects/Characters/MyChar/Famel/hair/hair_2.skin", 0); chrHair.NativeHandle.AddBinding(pSkinAttachment, newSkin);
but I can not create an "IAttachmentObject":

Code: Select all

IAttachmentObject pSkinAttachment = new IAttachmentObject();

P.S
first I wanted to attach all the clothes to the character in the editor and unnecessary hide, but the character will have a lot of clothes and weapons, so this option is not suitable.

Re: how to change attached skin? [C#]

Posted: Thu Mar 08, 2018 3:15 pm
by cry-miron
Creating a new IAttachmentObject is impossible, because it's just the interface in C++. Instead you would create an object that implements that interface, in your case the CSKINAttachment. However, the constructor for the CSKINAttachment is not available in C# at the moment (it's internal and requires an IntPtr to the unmanaged object) so in CRYENGINE 5.4 you can't create it with the new keyword. I'll see if I can add this to a future update of the engine, but it will not make it in for the 5.5 release since stabilisation for that release has already started.

What you could try is using GetIAttachmentObject on the IAttachment to get the already existing IAttachmentObject. The IAttachment is the NativeHandle of the CharacterAttachment in your example. Based on what you want to achieve this might be a solution for you.

Re: how to change attached skin? [C#]

Posted: Fri Mar 09, 2018 7:38 am
by amtp
is there a working code to change the skin?