fixed tambourine

such a stupid issue omg i can't believe it took me this long to realize what was happening. also added transition music into the caverns
This commit is contained in:
Sam
2023-05-06 17:16:35 -07:00
parent 726ef3d1be
commit a757a47af1
8 changed files with 212 additions and 90 deletions

View File

@@ -8,7 +8,7 @@ public class PlayerBehavior : MonoBehaviour
[Header("Physics:")]
private float _hInput;
private Rigidbody2D _rb;
private int forward = 1;
[HideInInspector] public int forward = 1;
public PlayerInput playerInput;
[Header("Tambourine:")]
@@ -382,9 +382,16 @@ public class PlayerBehavior : MonoBehaviour
// destroy all tambourines
GameObject[] currentTambourines = GameObject.FindGameObjectsWithTag("tambourine");
foreach (GameObject tambourine in currentTambourines) {
tambourine.GetComponent<TambourineBehavior>().DestroySelf();
// Destroy(tambourine);
print("tambs found: " + currentTambourines.Length);
if (currentTambourines != null) {
foreach (GameObject tambourine in currentTambourines) {
if (tambourine != null) {
tambourine.GetComponent<TambourineBehavior>().DestroySelf();
print("tamb destroyed");
} else {
print("null tamb");
}
}
}
StateController.Instance.RespawnPlayer();

View File

@@ -24,20 +24,18 @@ public class TambourineBehavior : MonoBehaviour {
void Awake() {
this.gameObject.GetComponent<CircleCollider2D>().enabled = true;
rb = this.gameObject.GetComponent<Rigidbody2D>();
animator = this.gameObject.GetComponent<Animator>();
animator = this.gameObject.transform.GetChild(0).gameObject.GetComponent<Animator>();
player = GameObject.FindGameObjectWithTag("Player");
}
void Start() {
// rb.AddForce(new Vector2(horizSpeed, vertSpeed), ForceMode2D.Impulse);
this.gameObject.transform.localScale = new Vector2(transform.localScale.x * player.GetComponent<PlayerBehavior>().forward, transform.localScale.y);
StartCoroutine(CheckToDestroy());
}
void Update() {
// if (Input.GetKeyUp(KeyCode.K)) {
// Destroy(this.gameObject);
// }
if (player == null) {
DestroySelf();
} else {
@@ -46,9 +44,9 @@ public class TambourineBehavior : MonoBehaviour {
// this.gameObject.transform.position = col.transform.position;
timeLerped += Time.deltaTime;
this.gameObject.transform.position = Vector2.Lerp(this.gameObject.transform.position, collidedObject.transform.position, timeLerped/timeToLerp);
if (this.gameObject.transform.position.x == collidedObject.transform.position.x && this.gameObject.transform.position.y == collidedObject.transform.position.y && !pinned) {
animator.SetBool("pinned", true);
if (this.gameObject.transform.position.x == collidedObject.transform.position.x && this.gameObject.transform.position.y == collidedObject.transform.position.y && !animator.GetBool("pinned")) {
pinned = true;
animator.SetBool("pinned", true);
tambourineHitSound.Play();
} else {
// print("pinned, but not same position: " + this.gameObject.transform.position + " / " + collidedObject.transform.position);