Checkpoints & movement

This commit is contained in:
OMGeeky
2022-05-23 19:06:14 +02:00
parent fc47e7d8f4
commit d14d23594e
71 changed files with 298792 additions and 3438 deletions

View File

@@ -0,0 +1,34 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace OMGeeky
{
public class Checkpoint : MonoBehaviour
{
private Animator animator;
private static readonly int IsActive = Animator.StringToHash( "IsActive" );
private void OnEnable()
{
animator = GetComponent<Animator>();
}
public void SetInactive()
{
if(animator != null)
animator.SetBool( IsActive, false );
}
private void OnTriggerEnter2D( Collider2D other )
{
if ( other.TryGetComponent( out Character character ) )
{
character.root.spawnPosition.SetInactive();
character.root.spawnPosition = this;
animator.SetBool( IsActive, true );
}
}
}
}