- Home /
transform.position = new Vector3 Bug or error
public void FindBlackCard(GameObject selected){
for (int i = 0; i <= 6; i++) {
var children = BottomFamily[i].GetComponentsInChildren<Selectable> ();
foreach (var child in children) {
if(!selected.GetComponent<Selectable>().inDeckPile){
if (child.faceUp && child.ColorOfCard == 0 && child.value == selected.GetComponent<Selectable> ().value + 1 && child.transform.childCount == 0) {
var positionC = child.GetComponentsInChildren<Transform> ();
foreach (var childTwo in positionC) {
//solitaire.bottoms [child.row].Add (selected.name);
solitaire.bottoms [selected.GetComponent<Selectable> ().row].Remove (selected.name);
selected.GetComponent<Selectable> ().row = child.row;
selected.transform.position = new Vector3 (childTwo.transform.position.x, childTwo.transform.position.y - 0.3f, childTwo.transform.position.z - yOffset);
selected.transform.parent = childTwo.transform;
}
}
else {
selected.transform.position = selected.transform.position;
}
}
else
{
if(child.faceUp && child.ColorOfCard == 0 && child.value == selected.GetComponent<Selectable>().value + 1 && child.transform.childCount == 0)
{
var positionC = child.GetComponentsInChildren<Transform> ();
foreach (var childTwo in positionC) {
selected.GetComponent<Selectable> ().inDeckPile = false;
selected.transform.position = new Vector3(childTwo.transform.position.x, childTwo.transform.position.y - 0.3f, childTwo.transform.position.z - yOffset);
solitaire.tripsOnDisplay.Remove(selected.name);
solitaire.deck.Remove (selected.name);
selected.GetComponent<Selectable> ().row = child.row;
solitaire.discardPile.Remove (selected.name);
selected.transform.parent = childTwo.transform;
//solitaire.bottoms [child.row].Add (selected.name);
}
}
else {
selected.transform.position = selected.transform.position;
}
}
}
}
}
when an object move to an position in Bottom row it just freeze there and does not move to any other position other than the Top position (for which i have an another script attached in my game).On clicking an card, it itself find the card on which it wants to move but after moving on an card it does not move on another card, say if the 9 of club is on 10 of hearts even after clicking on it does not goes to 10 of diamond even if it is faced-Up. So how can i fix this because it is an very important part of this game.
NOTE : the above script is just finding FindBlakCard there is also a FindRedCard in the big script AND
inDeckPile is in Deck Pile
faceUp is Faced-up (true or false)
value is the number of card(1-13)
suit is (S,D,H,C)
So Please Help me with this code
Thank You in Advance:)