• 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
Question by mdinizzz · Apr 05, 2012 at 12:57 AM · playerjoystickrespawn

Player Respawn with Joystick

hello, I'm using the dual touchpad that comes in the mobile assets, works as usual .. so that when the player died and respawned the joystick does not work should be somet$$anonymous$$ng in the prefab player that I created .. I cant noted that the dual touchpad on my Hierarchy in my clone (prefab player) .. what I do I do? how do I put the player into the dual touchpad prefab? I can not drag .. and already created a prefab for the dual touchpad and not working too .. a photo is an example: thanks for help

alt text

Comment

People who like this

0 Show 0
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

2 Replies

· Add your reply
  • Sort: 
avatar image

Answer by Hicsy · Dec 21, 2012 at 07:16 PM

$$anonymous$$, sorry for the necro, but seen as i looked everywhere for a solution and didn't find it, ill post my workaround so hopefully others get help later.

  • You can't drag a gameObject to a prefab, unless its a CHILD of that prefab - you'll understand why after a few weeks of using Unity but trust me on that for now...


    1/ "Tag" your joysticks with names:

  • "Tag dropdown -> add tag" at very top of inspector


    2/ Set up your scripts Start() function to attach the touchpads by TAG as per usual:

    // declare variables var deadZone: float = 0.3; // the amount of joystick movement before it reacts var moveTouchPad: GameObject; // t$$anonymous$$s eg. might be for a move script

    function Start() {
    if(!moveTouchPad) // if there was no joystick assigned in editor { moveTouchPad = GameObject.FindWithTag("LeftTouchPad"); // your tagged name } }


    3/ each game loop, look for input from t$$anonymous$$s modified script

    function FixedUpdate() { if (moveTouchPad.GetComponent(Joystick).position.y > 0+deadZone ) //note the GetComponent(Joystick) part { // move forward/up }

       if (moveTouchPad.GetComponent(Joystick).position.y  < 0-deadZone)
         {
             // move down/back
         }
     
     // now same t$$anonymous$$ng x2 for x-axis (strafe/turn)
     
     }
    
Comment

People who like this

0 Show 0 · Share
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

Answer by Quidam · Dec 21, 2012 at 09:46 PM

I may be misunderstanding your question, but assuming I'm not, I have a few ideas. First t$$anonymous$$ng's first, check to make sure your prefab "Player" has the Joysticks set up in the components. That way, when you spawn a prefab, the player already has the joysticks working. If they are in the prefab and still not working, see if you can put the "Dual Touchpads" object inside of your player's prefab. If that doesn't work, you should be able to select the joystick with a simple script. Sorry if I seem stupid about t$$anonymous$$s, I haven't made any mobile games.

T$$anonymous$$s script might work, but I'm just guessing since I haven't worked with mobile games.

 private var leftjoystick : GameObject;
 private var rightjoystick : GameObject;
 private var cont : PlayerController;
 private var fire : FireScript;
 
 function Start () {
     leftjoystick = GameObject.Find("Dual TouchPads/LeftTouchPad");
     rightjoystick = GameObject.Find("Dual Touchpads/RightTouchPad");
     cont = GetComponent(PlayerController);
     fire = GetComponent(FireScript);
 }
 
 function Update () {
 }
 
 function Respawn () {
     cont.script.Equals(leftjoystick);
     fire.script.Equals(rightjoystick);
 }
Comment

People who like this

0 Show 0 · Share
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

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Random Player Respawn Points 3 Answers

Respawn Time 1 Answer

How do I make my player re-spawn in its original place on collision of enemy? 1 Answer

Rotate the Player With Joystick 0 Answers

Respawn problem 2 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