Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

Unity Problems

A topic by PingGames created Nov 24, 2022 Views: 160 Replies: 2
Viewing posts 1 to 2

Please help me.  Today I added Levels to my game. In first place the Unity Editor crashed one time (if this is helpful). But them I made a commit (after I changed the position of my static enemy and added level) and then I closed my Unity. Then I opened VSCode and nearly all of the code was marked as uncorrect. 

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class WeaponBoardComputer : MonoBehaviour
{
    public Transform bulletPos;
    public GameObject _bulletPrefab;
    private float _timer;
    private GameObject _player;
    private void Start()
    {
        _player = GameObject.FindGameObjectWithTag("Player");
    }
    // Update is called once per frame
    void Update()
    {
        float distance = Vector2.Distance(transform.position, _player.transform.position);
        // Debug.Log(distance);
        if (distance < 30)
        {
            _timer += Time.deltaTime;
            if (_timer > 2)
            {
                _timer = 0;
                Shoot();
            }
        }
    }
    void Shoot()
    {
        Instantiate(_bulletPrefab, bulletPos.position, Quaternion.identity);
    }
}

Here's my Unity Project:

Here I can't see the enemy sprite (which is simple the Unity Deafult Sqaure).


Please help me!

Yours,

PingGames

Submitted

have you tried changing sprite's z position? Maybe it is rendering behind parent object.

Thank you for that hint. Actually the "Order in Layer" was set to 0 aswell as the Background so why I should see it 馃檪? The code "repaired" itself whyever. Thanks for your help.