45 lines
1.1 KiB
C#
Raw Normal View History

2023-06-12 14:07:20 +02:00
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;
2023-06-12 14:07:20 +02:00
// 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;
}
}
}