Search Unity

Problems with interact script

Discussion in 'Documentation' started by jordisoldevilamotta, Aug 4, 2020.

  1. jordisoldevilamotta

    jordisoldevilamotta

    Joined:
    Jul 21, 2020
    Posts:
    10
    Hello I'm working with an interact script that allows the player to interact with other gameobjects(players,doors,etc...).This is what I've done till now.I would also like to include an interaction with a an gameobject in order to make the simulation stop and finish.Thank you very much.

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. public class InteractObject
    6. {
    7.     private string action;
    8.     public InteractObject(string act)
    9.     {
    10.         action = act;
    11.     }
    12.     public void Interact()
    13.     {
    14.         if (action == "exemple")
    15.         {
    16.             Debug.Log("Has acabado la simulación");
    17.         }
    18.     }
    19. }