First I should explain how the card centering works. Using onmousedown() any clicks(left click or tap) on the cards bring them closer to the camera and centers by changing the handPos vector3, repositions the cards using reposition() and assigns handCentered to be true. Returning to the corner is same process but with the corner vector3 coordinate. The raycast is only casted when handCentered is true and on click, and the action is only performed when anything but a card is clicked on. The action being returning to the corner.
The behavior works as expected on everything, but the first card in the hand(going right to left). Clicking any other card centers the cards. There's a nested if statement that checks if the object hit by the raycast is a card or not, if it's NOT a card it does the corner repositioning. There's where the issue is, the raycast is ignoring the first card and hitting the plane below it causing the cards to instantly reposition back to the corner. For all the other cards, the raycast hits the card so the repositioning doesn't happen.
Using Debug.DrawRay(), I was able to see where the ray was casted. as well as using Debug.Log(hit.transform.gameObject.name + " " + hit.transform.position.x + " " +...), I see the name of the object that the ray hits in the console and it's x y z coordinate. On the first card Console shows Plane 0 1 0 so the ray cast is ignoring the card. On the other cards, the console displays Card(Clone) X Y Z for each card.
Has anyone else ran into an issue where raycast would ignore an object?
First I should explain how the card centering works. Using onmousedown() any clicks(left click or tap) on the cards bring them closer to the camera and centers by changing the handPos vector3, repositions the cards using reposition() and assigns handCentered to be true. Returning to the corner is same process but with the corner vector3 coordinate. The raycast is only casted when handCentered is true and on click, and the action is only performed when anything but a card is clicked on. The action being returning to the corner.
The behavior works as expected on everything, but the first card in the hand(going right to left). Clicking any other card centers the cards. There's a nested if statement that checks if the object hit by the raycast is a card or not, if it's NOT a card it does the corner repositioning. There's where the issue is, the raycast is ignoring the first card and hitting the plane below it causing the cards to instantly reposition back to the corner. For all the other cards, the raycast hits the card so the repositioning doesn't happen.
Using
Debug.DrawRay()
, I was able to see where the ray was casted. as well as usingDebug.Log(hit.transform.gameObject.name + " " + hit.transform.position.x + " " +...)
, I see the name of the object that the ray hits in the console and it's x y z coordinate. On the first card Console shows Plane 0 1 0 so the ray cast is ignoring the card. On the other cards, the console displays Card(Clone) X Y Z for each card.Has anyone else ran into an issue where raycast would ignore an object?