Code (CSharp): using System.Collections; using System.Collections.Generic; using UnityEngine; public class PlayerControl : MonoBehaviour { //Player's Bullet Prefab, BulletPositions public GameObject playerBulletGo; public GameObject bulletPosition01; public GameObject bulletPosition02; //what I tried //public Transform bulletPosition01; //public Transform bulletPosition02; //for the speed of Player public float speed; // Use this for initialization void Start () { } // Update is called once per frame void Update () { if (Input.GetKeyDown (KeyCode.Space)) { //instantiate bullets from position01 GameObject bullet01 = (GameObject)Instantiate (playerBulletGo); //seeting the bullet's initial posiiton bullet01.transform.position = bulletPosition01.transform.position; //instantiate bullets from position02 GameObject bullet02 = (GameObject)Instantiate (playerBulletGo); //seeting the bullet's initial posiiton bullet02.transform.position = bulletPosition02.transform.position; //what I tried // Instantiate (playerBulletGo, bulletPosition01); // Instantiate (playerBulletGo, bulletPosition02); } this is my code for making SpaceShooter 2D here for shooting bullets, in the video i am watching, first, instantiate the bullet's prefab and set the bullet's initial position by using transform.position property of shootingpositon game object but I tried another way, creating a public GameObject variable for bulltPosition and simply put "instantiate()" with second argument but the result was weird butllet was instantiate not from "bulletPosiiton" I want to know the rason Thank you
Check out the documentation for Instantiate You need to pass in a Vector3 for the position, and a Quaternion for rotation. So it would be bulletPosition01.transform.position, not just the game object itself. Instantiate(playerBulletGo, bulletPosition01.transform.position, Quaternion.identity)