decoamorim

Hey guys,

I belive i found a bug in Unity. If this was fixed in V3.0 would be nice to know when its out! :rofl:

The issue is this: we are creating a character's selection screen, so the attachment changes for the SkeletonRenderer must happen during the update. And when setting the command line in the update the meshes are losing its deformation, as its possible to see in the image below.



When setting the line for that attachment in the void Start, the deformation occurs, but the glove wont change when changing characters.

Would be super if someone have the light for this issue.

PS: When setting something as a bool just to make the change when pressing an input something weird happens, the gloves become random, but thats another issue that might be just our coding.
Developer/Founder at DCF Studios
http://www.studiosdcf.com/
Author of
Cruz Brothers[PS4 / STEAM] [upcoming on XboxOne] - http://www.cruzbrothersgame.com
Bunny Battle Arena[STEAM] - https://store.steampowered.com/app/872340/Bunny_Battle_Arena/
Аватара пользователя
decoamorim
  • Сообщения: 126

Pharan

Could you post some code? I'm having a hard time understanding your description.
Аватара пользователя
Pharan
  • Сообщения: 5366

decoamorim

Yes i could Pharan.


Here is the Code for the Character appearence.
The issue happens when this is in the Void Update

skeletoRenderer.skeleton.SetAttachment("gloveStandardFSlot", "luvas/modeloF" + playerLuvaToString);
skeletoRenderer.skeleton.SetAttachment("gloveStandardBSlot", "luvas/modeloT" + playerLuvaToString);

"Luvas" mean gloves, this is the slot for the gloves. The mesh is animated but when the code is in the update the animation is gone. It must be in the update because i want to change characters in the Vs screen.

The reason for this in the code :
/*if(trocaDeluva == true)
{
//LUVAS
skeletoRenderer.skeleton.SetAttachment("gloveStandardFSlot", "luvas/modeloF" + playerLuvaToString);
skeletoRenderer.skeleton.SetAttachment("gloveStandardBSlot", "luvas/modeloT" + playerLuvaToString);
trocaDeluva = false;
}*/

it was that i was trying to make the glove change during the Update for a few frames, and than animate. But with this on, the slot becomes radom, didnt find out why...
using UnityEngine;
using System.Collections;

public class PlayerApparelMenu : MonoBehaviour {

public int playerNumber;
SkeletonRenderer skeletoRenderer;

string playerSkinToString;
string playerCamisetaToString;
string playerBermudaToString;
string playerLuvaToString;
string playerHairToString;
string playerBeardToString;
string playerTenisToString;
public bool trocaDeluva = true;

// Use this for initialization
void Start()
{
skeletoRenderer = transform.root.GetComponent<SkeletonRenderer>();

SetStaticsToString();

skeletoRenderer.skeleton.SetAttachment("gloveStandardFSlot", "luvas/modeloF" + playerLuvaToString);
skeletoRenderer.skeleton.SetAttachment("gloveStandardBSlot", "luvas/modeloT" + playerLuvaToString);
}

void Update()
{
SetStaticsToString();

/*if(trocaDeluva == true)
{
//LUVAS
skeletoRenderer.skeleton.SetAttachment("gloveStandardFSlot", "luvas/modeloF" + playerLuvaToString);
skeletoRenderer.skeleton.SetAttachment("gloveStandardBSlot", "luvas/modeloT" + playerLuvaToString);
trocaDeluva = false;
}*/


skeletoRenderer.skeleton.SetAttachment("gloveStandardFSlot", "luvas/modeloF" + playerLuvaToString);
skeletoRenderer.skeleton.SetAttachment("gloveStandardBSlot", "luvas/modeloT" + playerLuvaToString);

//SKIN
skeletoRenderer.skeleton.SetSkin("skin" + playerSkinToString);


CamisetaSelected();
CabeloSelected();
BarbaSelected();

//BERMUDAS
skeletoRenderer.skeleton.SetAttachment("bermudaStandardFSlot", "bermudas/modeloF" + playerBermudaToString);
skeletoRenderer.skeleton.SetAttachment("bermudaStandardTSlot", "bermudas/modeloT" + playerBermudaToString);


//TENIS
skeletoRenderer.skeleton.SetAttachment("tenisSlotT", "tenis/modelo" + playerTenisToString);
skeletoRenderer.skeleton.SetAttachment("tenisSlotF", "tenis/modelo" + playerTenisToString);
}

void CabeloSelected()
{
//CARECA
if (playerHairToString == "0")
{

skeletoRenderer.skeleton.SetAttachment("cabeloStandardSlot", null);

} //CABELOS
else
skeletoRenderer.skeleton.SetAttachment("cabeloStandardSlot", "modelo" + playerHairToString);

}
void BarbaSelected()
{
//CARECA
if (playerBeardToString == "0")
{

skeletoRenderer.skeleton.SetAttachment("barbaStandardSlot", null);

} //CABELOS
else
skeletoRenderer.skeleton.SetAttachment("barbaStandardSlot", "modelo" + playerBeardToString);

}
void CamisetaSelected()
{

skeletoRenderer.skeleton.SetAttachment("camiseta", null);
skeletoRenderer.skeleton.SetAttachment("mangaT", null);
skeletoRenderer.skeleton.SetAttachment("mangaF", null);

if (playerCamisetaToString == "0")
{
skeletoRenderer.skeleton.SetAttachment("camisetaRegata", null);

}
else
skeletoRenderer.skeleton.SetAttachment("camisetaRegata", "modelo" + playerCamisetaToString);

}
void SetStaticsToString()
{

if (playerNumber == 1)
{
playerSkinToString = PlayerStatics.skinP1.ToString();
playerCamisetaToString = PlayerStatics.camisetaP1.ToString();
playerBermudaToString = PlayerStatics.bermudaP1.ToString();
playerLuvaToString = PlayerStatics.luvaP1.ToString();
playerHairToString = PlayerStatics.hairP1.ToString();
playerBeardToString = PlayerStatics.beardP1.ToString();
playerTenisToString = PlayerStatics.tenisP1.ToString();
}
else if (playerNumber == 2)
{
playerSkinToString = PlayerStatics.skinP2.ToString();
playerCamisetaToString = PlayerStatics.camisetaP2.ToString();
playerBermudaToString = PlayerStatics.bermudaP2.ToString();
playerLuvaToString = PlayerStatics.luvaP2.ToString();
playerHairToString = PlayerStatics.hairP2.ToString();
playerBeardToString = PlayerStatics.beardP2.ToString();
playerTenisToString = PlayerStatics.tenisP2.ToString();
}
}
This is the code that changes the Static variables that tell the skeletoRenderer what is in the slot.
void SwitchPlayersAppearencesP2()
{
switch (cursorP2Icon)
{
case 0:
PlayerStatics.nameP2 = "Marcus Luz";
PlayerStatics.camisetaP2 = 0;
PlayerStatics.bermudaP2 = 1;
PlayerStatics.luvaP2 = 0;
PlayerStatics.hairP2 = 1;
PlayerStatics.beardP2 = 1;
PlayerStatics.tenisP2 = 3;

break;

case 1:
PlayerStatics.nameP2 = "Felipe Cruz";
PlayerStatics.camisetaP2 = 0;
PlayerStatics.bermudaP2 = 4;
PlayerStatics.luvaP2 = 0;
PlayerStatics.hairP2 = 1;
PlayerStatics.beardP2 = 1;
PlayerStatics.tenisP2 = 0;

break;

case 2:
PlayerStatics.nameP2 = "Igor Cruz";
PlayerStatics.camisetaP2 = 0;
PlayerStatics.bermudaP2 = 0;
PlayerStatics.luvaP2 = 0;
PlayerStatics.hairP2 = 1;
PlayerStatics.beardP2 = 0;
PlayerStatics.tenisP2 = 0;

break;

case 3:
PlayerStatics.nameP2 = "Jeremy";
PlayerStatics.camisetaP2 = 5;
PlayerStatics.bermudaP2 = 3;
PlayerStatics.luvaP2 = 0;
PlayerStatics.hairP2 = 1;
PlayerStatics.beardP2 = 1;
PlayerStatics.tenisP2 = 2;

break;
Developer/Founder at DCF Studios
http://www.studiosdcf.com/
Author of
Cruz Brothers[PS4 / STEAM] [upcoming on XboxOne] - http://www.cruzbrothersgame.com
Bunny Battle Arena[STEAM] - https://store.steampowered.com/app/872340/Bunny_Battle_Arena/
Аватара пользователя
decoamorim
  • Сообщения: 126

Pharan

Okay, I see what's happening.

calling SetAttachment is slow, and calling it a lot every Update is not recommended for various reasons.
One of the reasons is that vertices are set whenever an Attachment is set.

Just call SetAttachment once whenever you change gloves. Don't call it every frame.

You're calling A LOT of things every frame that you probably shouldn't. ToString. SetSkin.
Аватара пользователя
Pharan
  • Сообщения: 5366

decoamorim

Thats was i was trying to with the bool system.
But than the slot becomes random, that might be coding so ill have to look into it.

Thanks for the tips Pharan, ill improve the code.
Developer/Founder at DCF Studios
http://www.studiosdcf.com/
Author of
Cruz Brothers[PS4 / STEAM] [upcoming on XboxOne] - http://www.cruzbrothersgame.com
Bunny Battle Arena[STEAM] - https://store.steampowered.com/app/872340/Bunny_Battle_Arena/
Аватара пользователя
decoamorim
  • Сообщения: 126

Pharan

What do you mean by "slot becomes random"?
Аватара пользователя
Pharan
  • Сообщения: 5366

decoamorim

Pharan писал(а):What do you mean by "slot becomes random"?
The gloves appear randomly.

It is a variable that governs whitch glove should appear. When i set the slot codeline in Update:
skeletoRenderer.skeleton.SetAttachment("gloveStandardFSlot", "luvas/modeloF" + playerLuvaToString);
skeletoRenderer.skeleton.SetAttachment("gloveStandardBSlot", "luvas/modeloT" + playerLuvaToString);
They get the topic bug, not deforming the mesh but they change correctly. When the variable is 1 glove1 appear, when its 2 the glove2 and so on.

But if i do this with the code:
if(trocaDeluva == true)
{
//LUVAS
skeletoRenderer.skeleton.SetAttachment("gloveStandardFSlot", "luvas/modeloF" + playerLuvaToString);
skeletoRenderer.skeleton.SetAttachment("gloveStandardBSlot", "luvas/modeloT" + playerLuvaToString);
trocaDeluva = false;
}
And set
trocaDeluva = true
when the player press a button to change the character, the gloves start to appear randomly but the variable still in the right number. It is weird, because thats to only thing i change, add the bool to the code (for the exact reason you told me to not to keep doing this on every frame).
Developer/Founder at DCF Studios
http://www.studiosdcf.com/
Author of
Cruz Brothers[PS4 / STEAM] [upcoming on XboxOne] - http://www.cruzbrothersgame.com
Bunny Battle Arena[STEAM] - https://store.steampowered.com/app/872340/Bunny_Battle_Arena/
Аватара пользователя
decoamorim
  • Сообщения: 126


Вернуться в Unity