Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 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 something 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
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

2 Replies

· Add your reply
  • Sort: 
avatar image
0

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

hi, 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; // this 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 this 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 thing x2 for x-axis (strafe/turn)
     
     }
    
Comment
Add comment · 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
0

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 thing'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 this, I haven't made any mobile games.

This 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
Add comment · 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.

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

Problem with multiple animation Controlle Script 2 Answers

Player Respawn After Death 1 Answer

Player taking damage on collision. Can't get the script to work!? 1 Answer

Respawn Player / enable new camera 0 Answers

Falling off respawn script 1 Answer


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