Forum begins after the advertisement:
-
::I keep getting two errors on the spikes script and i don’t know how to fix them.
View post on imgur.com
spikes script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Spikes : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
private void OnTriggerEnter2D(Collider2D _other)
{
if (_other.CompareTag("Player"))
{
StartCoroutine(RespawnPoint());
}
}
IEnumerator RespawnPoint()
{
PlayerController.Instance.pState.cutscene = true;
PlayerController.Instance.pState.invincible = true;
PlayerController.Instance.rb.velocity = Vector2.zero;
Time.timeScale = 0;
StartCoroutine(UIManager.Instance.sceneFader.Fade(SceneFader.FadeDirection.In));
PlayerController.Instance.TakeDamage(1);
yield return new WaitForSeconds(1);
PlayerController.Instance.transform.position = GameManager.Instance.platformingRespawnPoint;
StartCoroutine(UIManager.Instance.sceneFader.Fade(SceneFader.FadeDirection.Out));
yield return new WaitForSeconds(UIManager.Instance.sceneFader.fadeTime);
PlayerController.Instance.pState.cutscene = false;
PlayerController.Instance.pState.invincible = false;
Time.timeScale = 1;
}
}
::Change the rb
variable in PlayerController
from private
to public
, and change the fadeTime
variable in SceneFader
from private
to public
as well.