This question was
closed May 03, 2016 at 11:07 AM by
meat5000 for the following reason:
Duplicate Question
RTM/Do a little search.
Question by
chetan_dabhi · May 03, 2016 at 10:48 AM ·
instantiatebullet
How to shoot or spawn bullet with player direction in unity
Hello, In my unity 2D game I am generate bullet but issue is that bullet generate same position.it cannot generate with player direction or movement so how I can solve this issue
This is my Bullet Script
public class WeaponScript : MonoBehaviour {
public int speed=6;
public Rigidbody2D rd;
// Use this for initialization
void Start () {
rd = GetComponent<Rigidbody2D> ();
Vector3 v = rd.velocity;
v.x = speed;
rd.velocity = v;
}
}
This is my playerscript when i generate bullet
public void ShootWeapon(){
Instantiate (weaponShoot,transform.position,Quaternion.identity);
}
Comment
This is a seriously heavily covered topic. Its handed in the manual and in the tutorials and a google search brings many results. Perhaps start by searching out the Scripting API page for Instantiate to find out how the rotation factor works.
Follow this Question
Related Questions
Bullets are firing in the wrong direction. 1 Answer
randomly shoot using number generator 0 Answers
Moving a spawned shuriken 2 Answers