I give up to try again after 3-4 hours and need some help.
All what i want is create an object (prefab) on scene after player press Spacebar.
So my code now:
using UnityEngine;
using System;
public class PlayerController : MonoBehaviour
{
public GameObject missle;
public PlayerController()
{
}
void Update()
{
var x = Input.GetAxis("Horizontal") * Time.deltaTime * 150.0f;
var z = Input.GetAxis("Vertical") * Time.deltaTime * 3.0f;
transform.Rotate(0, x, 0);
transform.Translate(0, 0, z);
if (Input.anyKeyDown)
{
Debug.Log(Input.inputString);
if (Input.inputString == " ") {
missle = Instantiate(Resources.Load("Assets/Prefabs/Missle.prefab")) as GameObject;
};
}
}
}
And i keep getting error “The Object you want to instantiate is null.”
My path to prefab: