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 /
avatar image
0
Question by davidarcila3 · Mar 18, 2016 at 12:25 PM · unity 5spaceshooterspaceshipshmup

Space Shooter Player 2 ship is flipping when going into Play Mode

Hello everyone!

I'm modifying the Space Shooter Tutorial so that I can have 2 Players simultaneously (Offline Multiplayer).

I used part of the Couch Wars tutorial to learn how to assign different Inputs to the different players...so far, so good. I can control each Space Ship independently :)

Now, I want the Second Player (Red Ship) to look down at Player 1 (Blue Ship) when the game starts.

For this I did the following:

  1. Duplicated the Ship Prefab in the Hierarchy

  2. Change it's name to Player_P2

  3. Changed the Inputs in the Inspector

  4. Rotated manually the Red Ship 180 degrees in Y and moved it up in the Z Axis

Now i'm left with this:

alt text

The problem is that when I go into Play Mode, the Red Ship flips and looks "up".

alt text

This is how my Hierarchy looks.

This is how my Input > Axes looks.

This is how the Player2 Inspector looks.

And this is the PlayerController code:

 using UnityEngine;
 using System.Collections;
 
 [System.Serializable]
 public class Limite
 {
 public float xMin, xMax, zMin, zMax;
 }
 
 public class PlayerController : MonoBehaviour 
 {
     Rigidbody rb;
     public float fuerza, fuerzagiroz, fuerzagirox;
     public Limite lim;
 
     public string Disparar = "Fire_P1";
     public string MovimientoHorizontal = "Horizontal_P1";
     public string MovimientoVertical = "Vertical_P1";
 
     public GameObject Disparo;
     public Transform SpawnDisparo;
 
     public float FrecuenciaDisparo;
     private float siguienteDisparo;
 
     void Start()
     {
         rb = GetComponent<Rigidbody>();
     }
 
     void FixedUpdate () 
     {
     
         float movimientoHorizontal = Input.GetAxis (MovimientoHorizontal);
         float movimientoVertical = Input.GetAxis (MovimientoVertical);
 
         Vector3 movimiento = new Vector3 (movimientoHorizontal, 0f, movimientoVertical);
 
         rb.velocity = movimiento * fuerza;
 
         rb.rotation = Quaternion.Euler (rb.velocity.z * fuerzagirox, 0f, rb.velocity.x * -fuerzagiroz);
 
         rb.position = new Vector3 
         (
         Mathf.Clamp(rb.position.x, lim.xMin, lim.xMax) ,
         0f,
         Mathf.Clamp(rb.position.z, lim.zMin, lim.zMax)
         );
     }
 
     void Update()
     {
         if (Input.GetButton (Disparar) && Time.time > siguienteDisparo) 
         {
             siguienteDisparo = Time.time + FrecuenciaDisparo;
             Instantiate (Disparo, SpawnDisparo.position, Quaternion.identity);
         }
     }
 }


unity-2016-03-16-09-37-30.png (371.8 kB)
unity-2016-03-16-09-13-33.png (347.9 kB)
Comment
Add comment
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

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Freelancer of Freespace type Enemy Ai 2 Answers

[2D] How to instantiate laser when player rotates? 1 Answer

Strategies for Physics-based Movement for 2D Space RTS Controls? 1 Answer

How can i change the player controls in Space Shooter to Touch. 1 Answer

Performance view over spawn waves method 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