I’ve seen similar problems and the solutions, but it seems to work for everyone but me. The Player script has an orientation parameter, which is NONE at the start. Then in want to changue it, but i can’t.
GameObject playerInstance = Instantiate(player, new Vector3(spawn.x, PLAYER_HEIGTH, spawn.y), Quaternion.identity) as GameObject;
Player playerScript = playerInstance.GetComponent();
playerScript.setOrientation(directionType.NORTH);
Debug.Log(playerInstance.GetComponent().orientation);
THe Debug returns the right orientation, so, somehow, it changues it. But in game the variable is still NONE.
You gave very little information about your setup, what exactly “directionType” is (i guess it’s an enum) and what exactly happens inside setOrientation. Furthermore you forget to mark your code as code so your generic parameter got interpreted as HTML tag and got stripped away.
So please take the time to read the userguide, especialle the section “Posting Questions, Answers andComments”. So feel free to edit your question and re-add your code properly highlighted. You also might want to include what “setOrientation” does and what kind of thing actually should change about the object.
Next, make sure you actually inspect the right object in the hierarchy. For this i recommend to rename the instance in code so you can be sure that’s the right one.
playerInstance.name = "The One";
Next thing you can do is to add a context object to your Debug.Log. That way when you click the debug message in the in the console it will “ping” the object in the hierarchy:
If that still doesn’t give you the right object / values, try isolating that problem by copying the relevant parts into a new / empty project and see if the problem exists there as well. If it does, feel free to add more information to your question. We only see those parts of your problem that you are willing to share. You are at the source, we don’t.