Hello everyone ,
I have a problem with my 2D scroller shooting game (like metal slug), basically I'm not able to create a script to shoot in front of the player . I've created one , but the bullet doesn't move in front of the player , and it keep staying where it was spawned (the actual player position). Here's my script :
var Sparo_pref : Transform;
function Update ()
{
if(Input.GetAxis("Spara")){
var bullet = Instantiate(Sparo_pref, Vector3(transform.position.x,transform.position.y,0), Quaternion.identity);
bullet.rigidbody.AddForce(bullet.transform.forward * 5);
}
Can someone help me, please? I have been searching a solution for couple of days , but nothing happens...
Edit : code sample ;)
↧