Advertisement
sphinx2001

InteractionController

May 27th, 2020
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.83 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class InteractionController : MonoBehaviour
  6. {
  7.     public bool InteractionTrue;
  8.     public bool Icon;
  9.     public float speed;
  10.     public GameObject IconGame;
  11.     public Transform Point1;
  12.     public Transform Point2;
  13.  
  14.     // Use this for initialization
  15.     void Start()
  16.     {
  17.  
  18.     }
  19.  
  20.     // Update is called once per frame
  21.     void Update()
  22.     {
  23.         float step = speed * Time.deltaTime;
  24.         if (Icon == true)
  25.         {
  26.             IconGame.SetActive(true);
  27.             Icon = false;
  28.         }
  29.         else
  30.         {
  31.             IconGame.SetActive(false);
  32.         }
  33.         if (InteractionTrue == true)
  34.         {
  35.             gameObject.transform.position = Vector3.MoveTowards(transform.position, Point2.position, step);
  36.         }
  37.         else
  38.         {
  39.             gameObject.transform.position = Vector3.MoveTowards(transform.position, Point1.position, step);
  40.         }
  41.     }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement