Unity 3d [2018.1]

Hi, I downloaded the lasted version of Unity 3D and my card games collection fingers input respond alot better when players touch the screen on cards. Happy for that. But…

I think i currently get code line instruction skip. Sometimes, the ads don’t show. Sometimes. the cards are not displayed after an animation. things like that.

I use the fonction Update to do animations. (I currently skipfame by mutilplying the new positions to get speed)

i use a fonction for Max Famerate at 18.0f because the telephone and tablets cannot render my game more than 20 frame/sec.

Cards are on high resolutions, i think it’s probably for that.

In the profiler, almost all the ressources are used for the update fonction.

In the update fonction, i use it for all animations and for detecting actions.

(I dont use SetPosition, just change x,y position with transform)

After the distribution of a card animation (2018.1) the card is not displayed in hand. I used close the fontion in the update and after i enable the Canvas with my card image inside as a button. And after that i assign in the ressource folder the image of the card to the button. Send, Show, send, show, send, show. it’s something very fast.

Something weird, after i distribute the cards. i sort them and In THAT TIME… the cards appears. The sort fonction is not in related to the Update() fonction and it’s near the update fonction.

I mostly use basic code to do it since i’m a n00b. The Bull game takes almost 80 000 codes lines. Speed game takes about 30 000 lines.

And yes, the players panels display a black line around my shadow already include in the graphics since Unity 2017… The shadow is not detecting alpha channel.

It’s my first game project. Any tips or advice to enhance it ? And how to fix my bug ?

https://ibb.co/hSrduS
https://ibb.co/cYsjZS
https://ibb.co/mh4bg7

Philippe Pelchat

You will need to show your code. You mention “I think i currently get code line instruction skip”, you will need to confirm. Use Debug.Log statements to confirm your logic flow.

The current code work well in 2017 – but in 2018, the cards are not displayed in hand.

//CALLED IN UPDATE ();

void sendcardstoplayers () {

animatedSendCard2();
animatedSendCard4();

}

void animatedSendCard4 () {

if (PlayerPrefs.GetInt (“cardSending2”) == 4) {

if (movespeedy2 > -234.0f) {

movespeedx2 = movespeedx2 + ((5.0f + 10.0f) * 2.5f); //SPEED
movespeedy2 = movespeedy2 - ((7.0f + 10.0f) * 2.5f); //SPEED
rotateramdomspeed = UnityEngine.Random.Range (0.0f, -5.0f);
rotatespeed = rotatespeed + rotateramdomspeed;

cardsended1 = GameObject.Find (“cvs_back_dist_cards_tosendl”).GetComponent ();
cardsended1.transform.localPosition = new Vector3 (movespeedx2, movespeedy2, 0f);
cardsended1.transform.eulerAngles = new Vector3 (0.0f, 0.0f, rotatespeed);

} else {

PlayerPrefs.SetInt (“cardSending2”, 0);

cardsended1.transform.localPosition = new Vector3 (-128, ystartpoint, 0.0f);
cardsended1.transform.eulerAngles = new Vector3 (0.0f, 0.0f, 0.0f);
movespeedy2 = ystartpoint;
movespeedx2 = -128;
rotatespeed = 0.0f;

cardsended1 = GameObject.Find (“cvs_back_dist_cards_tosendl”).GetComponent ();
cardsended1.transform.localPosition = new Vector3 (movespeedx2, movespeedy2, 0f);
cardsended1.transform.eulerAngles = new Vector3 (0.0f, 0.0f, rotatespeed);

backcardcountermain = backcardcountermain - 1;
maintradecounter = maintradecounter + 1;
pcardcounter = pcardcounter + 1;

Text temptxt = GameObject.Find (“txt_player_msg_game_pts_main”).GetComponent ();
temptxt.text = (20 - maintradecounter).ToString();

disturbrotatex = UnityEngine.Random.Range (-1.0f, 1.0f);
disturbrotate [pcardcounter] = disturbrotate [pcardcounter] + disturbrotatex;
rotateramdomspeed = UnityEngine.Random.Range (-1.0f, 1.0f);
distanceforcardx = UnityEngine.Random.Range (-1.0f, 1.0f);
distanceforcardy = UnityEngine.Random.Range (-1.0f, 1.0f);

Debug.Log ("##### COUNTER : " + pcardcounter);
cardback = GameObject.Find (“cvs_pcards” + pcardposition [pcardcounter].ToString ()).GetComponent ();
cardback.enabled = true;

cardsended1.transform.localPosition = new Vector3 ((pcardpositionx [pcardcounter] - distanceforcardx), (pcardpositiony - distanceforcardy), 0f);
//cardback.transform.eulerAngles = new Vector3 (0.0f, 0.0f, disturbrotate [pcardcounter]);

// cardsended = GameObject.Find (“cvs_back_dist_cards_tosendl”).GetComponent ();
// cardsended.enabled = false;

/////////////LOAD CARD
cardimg = GameObject.Find (“cvs_pcards” + pcardposition [pcardcounter].ToString ()).GetComponentInChildren ();
cardimg.sprite = Resources.Load (“Adecke/Cards/” + cardstyle + " cards/" + cardstyle + “_” + PlayerPrefs.GetInt (“turncards_main” + pcardposition [pcardcounter].ToString ()));
Debug.Log (" Card Number " + PlayerPrefs.GetInt (“turncards_main” + pcardposition [pcardcounter]));
Debug.Log (" Card Counter " + pcardcounter);
Debug.Log (" Cards position " + pcardposition [pcardcounter]);
cardsended1 = GameObject.Find (“cvs_back_dist_cards” + backcardcountermain.ToString ()).GetComponent ();
cardsended1.enabled = false;

totalcardcountertest = PlayerPrefs.GetInt (“carddistributed_main”);
cardcountertest = cardcountertest + 1;
totalcardcountertest = totalcardcountertest + 1;
PlayerPrefs.SetInt (“carddistributed_main”, totalcardcountertest);

PlayerPrefs.SetInt (“soundPlayBull”, 0);

Debug.Log ("Card Counter " + cardcountertest);
Debug.Log ("P Card Counter " + pcardcounter);
Debug.Log ("Back Card Counter " + backcardcounter);

if (maintradecounter > 4) {

cardsended1 = GameObject.Find (“cvs_back_dist_cards_tosendl”).GetComponent ();
cardsended1.enabled = false;

mainsendedcards = 1;
PlayerPrefs.SetInt (“startgame”, 1);

Debug.Log (“SHORT AND SAVE”);

} else {

PlayerPrefs.SetInt (“cardSending2”, 4);

}
}
}
}

Usually physics calls are put in FixedUpdate not Update. Also, you didn’t confirm if all your debug.log statements are being executed as you expect.

I just come back to 2017 because i needed to publish a bug fix quicly. sorry.