Unity3D从零打造王者荣耀·王者班 扫二维码继续学习 二维码时效为半小时

(0评价)
价格: 4598.00元

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerManager : MonoBehaviour
{
    public GameObject player1;
    public GameObject player2;
    private GameObject startPoint;
    private GameObject player;
    private GameObject startPointss;
    private GameObject play;
    private int playertast;
    // Use this for initialization
    void Start()
    {
        if (playertast == 0)
        {
            startPoint = GameObject.Find("startPoint");


            addplay(player1);


        }
        else if (playertast == 2)
        {
            startPointss = GameObject.Find("startPointss");


            addpl(player2);
        }

    }

    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Alpha1))
        {
            addplay(player1);

        }

        if (Input.GetKeyDown(KeyCode.Alpha2))
        {
            addpl(player2);
        }

       
    }
    void addplay(GameObject obj)
    {
        Destroy(player);
        Destroy(play);
        player = Instantiate(obj, startPoint.transform.position, Quaternion.identity);

       
    }


    void addpl(GameObject obj)
    {
        Destroy(player);
        Destroy(play);
        startPointss = GameObject.Find("startPointss");
        play = Instantiate(obj, startPointss.transform.position, Quaternion.identity);
    }

}

[展开全文]
weiqing · 2022-07-20 · 1