Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
This question was closed Apr 01, 2016 at 06:32 PM by Pendleburt for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by Pendleburt · Mar 31, 2016 at 11:53 AM · bugcharacterprogramminggameplay

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;
     }
Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Pendleburt · Mar 31, 2016 at 11:51 AM 0
Share

There is more to the script than that but that's the part which I'm currently struggling with, it's line7.

0 Replies

  • Sort: 

Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

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


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges