Quantcast
Channel: Questions in topic: "parenting"
Viewing all articles
Browse latest Browse all 302

Some Box Collider 2Ds seem to shift on some instances of a prefab

$
0
0
I've been banging my head against the desk for hours. I hope someone can help me with this.

The issue is: Some Box Collider 2Ds aren't clickable, even though those Box Colliders are objects on instances from the same parent prefab.

I'm newish to Unity and C#, but I've tried to be as detailed as possible below. This is my first time posting a question here, so I hope I'm doing it adequately.

First, here's a video showing the issue. As you can see, when I hover over each of the card stats on the card, the yellow triangle sprite appears, as expected. This behavior is consistent for the first two cards in the stack. However, on the third card, only the bottom two card stats operate according to my expectation.

https://youtu.be/vFu0Q2kXrN4

I checked to see if the OnMouseOver() method was even reacting to the first 4 card stats on card three. It isn't. So, for some reason OnMouseOver() stops behaving as expected. This is especially strange considering that the Box Collider 2Ds do appear to be active and in the correct position (according to the Scene view during run-time, see image below)

![alt text][1] I then thought that maybe the z position of the cards themselves are causing a complication, but even when I set all of the z positions to 0, the issue persists.

Also, I tried adjusting the x and y positions of each card, just to search for different behavior, but the issue persists.

The cards are dealt at Start() from a GameManager script attached to the main camera: //player cards behavior Shuffle(playerCards); pxpos = 6f; pypos = -1f; pzpos = 0f; for (int i = 0; i ().stat0; break; case "stat1": playerStat = cardBehavior.stat1; computerStat = computerTopCard.GetComponent().stat1; break; case "stat2": playerStat = cardBehavior.stat2; computerStat = computerTopCard.GetComponent().stat2; break; case "stat3": playerStat = cardBehavior.stat3; computerStat = computerTopCard.GetComponent().stat3; break; case "stat4": playerStat = cardBehavior.stat4; computerStat = computerTopCard.GetComponent().stat4; break; case "stat5": playerStat = cardBehavior.stat5; computerStat = computerTopCard.GetComponent().stat5; break; default: playerStat = 0; break; } //Debug.Log("Player " + gameObject + " of " + playerStat + " vs Computer " + computerTopCard + " of " + computerStat); }

I'm absolutely at a loss. Any help is much appreciated! [1]: /storage/temp/185808-boxcolliders.png [2]: /storage/temp/185805-prefab.png

Viewing all articles
Browse latest Browse all 302

Latest Images

Trending Articles





Latest Images