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

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)

}

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);
}