Search Unity

PlayerController for two GameObject

Discussion in 'AR/VR (XR) Discussion' started by CorentinBringer, Jan 15, 2020.

  1. CorentinBringer

    CorentinBringer

    Joined:
    Nov 30, 2017
    Posts:
    1
    Hello,

    I want to create a little pokemon game for learn with AR. Actually when the camera detect two image (dracaufeuCard et tortankCard) Charizard and Blastoise appear. Bu if I click on attack button one of this pokemon acive their particules effect for make a attack during 2s.
    Now I want to make a playerController for define live and power attack for the pokemon but I know how to do it.
    This is my DracaufeuScript, it's same for TortankScript.

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.UI;
    5.  
    6. public class DracaufeuScript : MonoBehaviour
    7. {
    8.  
    9.     public Button attackButton1;
    10.     public GameObject fireBall;
    11.  
    12.     // Start is called before the first frame update
    13.     void Start()
    14.     {
    15.         attackButton1.onClick.AddListener(performAttack);
    16.         fireBall = gameObject.transform.FindChild("FireBall").gameObject;
    17.         fireBall.gameObject.SetActive(false);
    18.     }
    19.  
    20.     // Update is called once per frame
    21.     void Update()
    22.     {
    23.        
    24.     }
    25.  
    26.     IEnumerator Wait() {
    27.         fireBall.gameObject.SetActive(true);
    28.         yield return new WaitForSeconds(2);
    29.         fireBall.gameObject.SetActive(false);
    30.     }
    31.  
    32.     void performAttack() {
    33.         StartCoroutine(Wait());
    34.     }
    35. }
    36.  
    Thanks or your help