The question is answered, right answer was accepted
Changing player co-ordinates
Hi
Basically I have two characters, a 2D and a 3D character. I have written a script that allows me to swap between the two upon a key press, it moves the 2D character to the 3D's position and then disables the 3D character or the other way round when swapping back to 2D.
When I swap from back from the 3D to the 2D I want to change the 2D character's Z co-ordinate to 0, but keep the x and y the same. For some reason it just sets the 2D character to the same position each time even if I move all the way off to the right side of the screen it still appears in the same position.
Here's my code...
void Update ()
{
if (Input.GetKeyDown (KeyCode.Q)) //Go 2D
{
if (number == 0)
{
Player1.gameObject.SetActive (true);
Player1.transform.position = Player2.transform.position;
Player1.gameObject.transform.position = new Vector3(transform.position.x, transform.position.y, 0);
Player2.gameObject.SetActive (false);
GetComponent<AudioSource> ().Play ();
Debug.Log ("BACK TO 3D");
number =+ 1;
}
There is more to the script than that but that's the part which I'm currently struggling with, it's line7.
Follow this Question
Related Questions
Help with Enemy IA walk-Attack-Retreat Jumping-wait-repeat 0 Answers
Character falls when animator plays 0 Answers
How would do I play a walking animation when i move my joystick? 0 Answers
PAUSE MENU - - If i press "w" and "space change scene.. 0 Answers
How can adjust a different touch spots on the object 0 Answers