Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

When ever i instantiate my enemy it turns invisible

Discussion in '2D' started by Mythtec, Jul 6, 2020.

  1. Mythtec

    Mythtec

    Joined:
    Jun 2, 2020
    Posts:
    4
    So I made a simple enemy with following A.I. and the ability to harm the player upon contact and it works perfectly it dies when it should ect and I made a enemy summoning script that summons enemies at a certain location every 2 second but despite the game object I put in place to instantiate working it turns invisible only in the game view it can be seen in the scene view and it cant harm the player but it can still follow the player.

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. public class CMONDUDE : MonoBehaviour
    6. {
    7.     public GameObject here;
    8.     public GameObject WhatToSpawn;
    9.     public float TimeBetweenSpawns;
    10.     private float SpawnTime;
    11.  
    12.     private void Update()
    13.     {
    14.         SpawnTime -= Time.deltaTime;
    15.         if (SpawnTime <= 0)
    16.         {
    17.             summon();
    18.             SpawnTime = TimeBetweenSpawns;
    19.         }
    20.     }
    21.     void summon()
    22.     {
    23.         Instantiate(WhatToSpawn, here.transform.position, Quaternion.identity);
    24.     }
    25. }
     
  2. Mythtec

    Mythtec

    Joined:
    Jun 2, 2020
    Posts:
    4
    Update I fixed the visual glitch but now I'm trying to figure out why the collision isn't working
     
  3. Redlar

    Redlar

    Joined:
    Aug 17, 2016
    Posts:
    16
    What are the collider settings in the Inspector?
     
  4. Mythtec

    Mythtec

    Joined:
    Jun 2, 2020
    Posts:
    4
    I fixed the problems thanks for your concern