• Andrew Jonhardt

Behind in more ways than one

I almost didn't POST this week. Get it? Cause computers have to power-on self-test when they start and my posting of blogs is kinda like a self-review I have to do and-

This is what happens when I write in the morning.

Bad news:

I didn't make as much progress this past weekend as I'd like. There's only 3 weekends left until SXSW, and I still have to program most of the card mechanics and make the AI play cards. I've also realized I need to institute pop-up panels for some mechanics, and the whole process of making a giant card has taught me I don't know how to do pop-ups efficiently. I'll need to do more research.

Good news:

Acceleration cards are currently moving the player markers on the Distance Track! The code to get this working was actually alot simpler than I realized:

Transform temp; //trying to get temp variable so I can extract the name.

if(curPlayer == 0 && p2Acc.childCount > 0) //I fucked up, so 0 is actually p2, and 1 is p1.


for(int c = 0; c < p2Acc.childCount; c++)


temp = p2Acc.GetChild(c);





In the above code snippet (I haven't figured out how to effectively illustrate code in a blog yet), I:

  • Create a temporary Transform-type variable called Temp.

  • Check the current player (curPlayer) and whether that player's Acceleration card area has any cards. In this example, I'm checking player 2's Acceleration area.

  • Initiate a for loop to cycle through in-play Acceleration cards, which are set as child objects of the Acceleration board area, before assigning data from each card (the Transform, specifically) to Temp.

  • Extract the name of the card from its Transform and pass it along to another function.

As you may (or may not) guess, the 2nd function is yet another place where I've listed a bunch of card names. The function in question, moveCalc, is where I'm currently planning to manage all of my Acceleration card mechanics.

However, Distance Track movement doesn't end with 2 functions in 1 script. All that moveCalc is doing is setting information into a variable called carMove. carMove is being referenced by an entirely different script, located on the Distance Track tokens, that is responsible for moving the tokens a specified distance. In order to make this work, I had to learn how to interact with RectTransforms.

RectTransform is the Transform type associated specifically with Unity UI objects. You can pass data to them using normal Transform commands, but the results are unlikely to be what you want. The following code is what I used to set a starting position for my tokens (from a Start() function):

selfRecTrans = GetComponent<RectTransform>();

curSpotX = distNodes[0].anchoredPosition.x;

curSpotY = distNodes[0].anchoredPosition.y;

selfRecTrans.anchoredPosition = new Vector2(curSpotX,curSpotY);

Once I got this worked out (with a little help from the Unity docs), actual token movement referencing the carMove variable was much easier:

for(int i = 0; i< boardState.carMove; i++)


curSpotX = distNodes[spacesMoved].anchoredPosition.x;

curSpotY = distNodes[spacesMoved].anchoredPosition.y;

selfRecTrans.anchoredPosition = new Vector2(curSpotX,curSpotY);



Car tokens now smoothly calculate and move 1 space for every value stored in carMove. Well, not "smoothly" per se as movement is instant. What I mean is that tokens are not stumped by moving from space 15 to 16 (these spaces are on either end of the Distance Track).

Finally, I wrapped up the weekend by writing something that blew my non-programmer mind:

public GameObject bigCardAcc;

bigCardAcc = GameObject.FindObjectOfType<StateTrack>().bigCard;

What we have here, is an example of pulling another variable straight out of another script directly into a new variable that happens to be of the same type (in this case, both variables are GameObject type). For some reason, I didn't know you could do this. It's probably not best practice. Regardless, this is the solution I had to make to solve my large reference card breaking for no apparent reason. I'm proud of it.

Gotta take your small victories. Until next week.

© 2023 by Andrew Jonhardt. Proudly created with Wix.com