(1人评价)
Unity3D从零打造王者荣耀·第四季:游戏角色和怪物逻辑
价格 ¥ 238.00
该课程属于 Unity3D从零打造王者荣耀·王者班 请加入后再学习

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

}

[展开全文]

授课教师

老师

课程特色

视频(53)