2023-06-12 15:29:51 +02:00

45 lines
1.1 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ButtonDOne: MonoBehaviour
{
public SpriteRenderer spriteRenderer;
public Sprite originalSprite;
public Sprite activatedSprite;
public GameObject movingPoint;
public Vector3 activatedPointPosition;
private Vector3 originalPointPosition;
public bool einsAn = false;
public bool zweiAn = false;
public bool dreiAn = false;
// Start is called before the first frame update
void Start()
{
originalPointPosition = movingPoint.transform.position;
}
// Update is called once per frame
void Update()
{
}
void OnTriggerEnter2D(Collider2D other) {
if (other.CompareTag("PressurePlatable") || other.CompareTag("PlayerIsOnIt")){
spriteRenderer.sprite = activatedSprite;
movingPoint.transform.position = activatedPointPosition;
einsAn = true;
}
}
void OnTriggerExit2D(Collider2D other) {
if (other.CompareTag("PressurePlatable")|| other.CompareTag("PlayerIsOnIt")) {
spriteRenderer.sprite = originalSprite;
movingPoint.transform.position = originalPointPosition;
einsAn = false;
}
}
}