I have two scripts on the same object. The first script Piece.cs just holds a some data about the object in somepublic variables, one of them variables is an interger called “Faction”. The other script PC.cs responds to collisions. When a trigger collider goes off the script PC.cs executes some code. In that code I need to grab some data that exists in Piece.cs so I was hoping I could just reference that script from inside PC.cs something like this…
int faction = Piece.Faction;
kinda like he way you can reference the transform of he object, but I can’t I have to do this…
private Piece thisPiece = null; //the Piece script on this object
.
.
.
thisPiece = gameObject.GetComponent<Piece>();
int faction = thisPiece.Faction;
I’m cool with doing it this way, but if there is a way to directly get the Faction property in the Piece.cs class, I rather do it that way.