When I play my transform changes and I have set the prefab to the same position to be sure, I am trying to make my bullet fire out of my gun barrel here is the script
using UnityEngine;
using System.Collections;
public class Shooting : MonoBehaviour {
public Rigidbody BulletPrefab;
public float speed = 100f;
// Update is called once per frame
void Update () {
if (Input.GetMouseButtonDown(0)){
Rigidbody BulletInstance;
BulletInstance = Instantiate(BulletPrefab, transform.position, transform.rotation) as Rigidbody;
BulletInstance.AddForce(transform.forward * speed);
}
}
}
thanks!
Make sure that "transform" is located at the gun muzzle.
– Simon-Larsenwhat exactly is the problem you are having?
– superluigiMy bullets spawn above my player even if I move the transform of my bullet spawn point
– Epic_1and my spawn is placed at the muzzle but it just spawn over my player
– Epic_1