Pressure Plates für Objects mit Tag PressurePlatable hinzugefügt und eins nur für Player, mit dementsprechenden Tag als Player of course. Ändert aktuell nur den Sprite beim betreten

This commit is contained in:
Dominik
2023-05-04 12:38:52 +02:00
parent 843f5fa1ba
commit 31b0666c93
16 changed files with 1989 additions and 2 deletions

View File

@@ -0,0 +1,33 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ObjPressurePlate: MonoBehaviour
{
public SpriteRenderer spriteRenderer;
public Sprite originalSprite;
public Sprite activatedSprite;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
void OnTriggerEnter2D(Collider2D other) {
if (other.CompareTag("PressurePlatable")) {
spriteRenderer.sprite = activatedSprite;
}
}
void OnTriggerExit2D(Collider2D other) {
if (other.CompareTag("PressurePlatable")) {
spriteRenderer.sprite = originalSprite;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 6c98bff63d012cd46ae3f1da27d9c742
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,33 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerPressurePlate: MonoBehaviour
{
public SpriteRenderer spriteRenderer;
public Sprite originalSprite;
public Sprite activatedSprite;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
void OnTriggerEnter2D(Collider2D other) {
if (other.CompareTag("Player")) {
spriteRenderer.sprite = activatedSprite;
}
}
void OnTriggerExit2D(Collider2D other) {
if (other.CompareTag("Player")) {
spriteRenderer.sprite = originalSprite;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: f4fc276bfd5b40942b9ca5950733343d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: