- Home /
Question by
Oweni · May 22, 2016 at 11:30 AM ·
c#bulletspawning problems
Bullet spawn issue

Hi, for some reasons, my bullet does not spawn where I tell it to. I have followed a few tutorials starting with the Unity instantiate tutorial to do it but it won't work. Here is the code: Animation anim; AudioSource gunSound; public Rigidbody bullet; public Transform spawnPoint;
void Start()
{
anim = GetComponent<Animation>();
gunSound = GetComponent<AudioSource>();
}
void Update()
{
if (Input.GetButtonDown("Fire1"))
{
Rigidbody bulletInstance;
bulletInstance = Instantiate(bullet, spawnPoint.position, spawnPoint.rotation) as Rigidbody;
bulletInstance.AddForce(spawnPoint.forward * 1000f);
gunSound.Play();
//anim.Play("GunShot4");
}
}
unity-spawn-problem-fileminimizer.jpg
(63.7 kB)
Comment
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Make my gun model fire bullets 1 Answer
Bullet fires before direction change 0 Answers
How to spawn GameObject exactly in front of another object? 3 Answers