Question by
morian35 · Jun 07, 2020 at 09:10 PM ·
c#scripting problemscenerespawn
i need help with enemy respawn
hi i i am new at c# and unity iam making a game so the problem that when i respawn object (enemy) the object is respawn in the scene but not in the game mode so can some one help me to know where is the problem
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class EnemyScript : MonoBehaviour
{
public Transform SpawnPoint;
SpriteRenderer spriteRenderer;
void Start()
{
spriteRenderer = GetComponent<SpriteRenderer>();
}
void Update()
{
}
private void OnTriggerEnter2D(Collider2D collision)
{
if (collision.gameObject.CompareTag("Player"))
{
spriteRenderer.enabled = false;
transform.position = SpawnPoint.position;
spriteRenderer.enabled = true;
}
}
}
Comment