@vadimgenuis

Как исправить ошибку GameObject Bullet is a prefab, it can't be spawned.?

Код

using UnityEngine;
using UnityEngine.Networking;
using UnityEngine.UI;

public class MPPLayer : NetworkBehaviour
{
    private Rigidbody2D rig;
	[SerializeField] private float Speed = 5;
	public static GameObject bullet;
	
    void Start()
    {
        rig = GetComponent<Rigidbody2D>();
    }
	
    private void FixedUpdate()
    {
		if(!isLocalPlayer){
			return;
		}
		float H = Input.GetAxis("Horizontal");
		rig.velocity = new Vector2(H*Speed, 0);
		
		if(Input.GetKeyDown("space"))
		{
			GameObject BulletPR = (GameObject)Resources.Load("Prefabs/MP/Bullet", typeof(GameObject));
			NetworkServer.Spawn(BulletPR);
			//Vector2 wruseyr = transform.position + new Vector3(0,1.5f,0);
			//Quaternion qweqwe = Quaternion.Euler(0,0,90);
			//Instantiate(BulletPR,transform.position + new Vector3(0,1.5f,0),Quaternion.Euler(0,0,-90));
		}
	}
	
	public override void OnStartLocalPlayer()
	{
		GetComponent<SpriteRenderer>().color = Color.red;
		gameObject.tag = "Player";
		base.OnStartLocalPlayer();
	}
}


Ошибка

GameObject Bullet is a prefab, it can't be spawned. This will cause errors in builds.
UnityEngine.Networking.NetworkServer:Spawn (UnityEngine.GameObject)
MPPLayer:FixedUpdate ()

  • Вопрос задан
  • 102 просмотра
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Похожие вопросы