mirror of
https://github.com/OMGeeky/GameDevGameJamV2.git
synced 2026-01-07 03:57:12 +01:00
Checkpoints & movement
This commit is contained in:
34
Assets/Scripts/Checkpoint.cs
Normal file
34
Assets/Scripts/Checkpoint.cs
Normal 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 );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user