early prototype D level
This commit is contained in:
42
Assets/AssetsFORELLE/Script/ButtonDOne.cs
Normal file
42
Assets/AssetsFORELLE/Script/ButtonDOne.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
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;
|
||||
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user