Change script from 3d to 2d Game.

Hello everyone.

Currently I have a script Which fires projectiles That works well in 3D.

I need help to change it in 2d shot. I added Rigidbody2D. By testing the script works, but the shot does not travel on the axis x or -x. the shot explodes in front of the character in 2D without traveling on the axis X.
How can you change this script from 3d to 2d shot?

#pragma strict
var Prefab : Transform;
var PrefabSpeed : float = 6000;

function Update () 
   if(Collisions.GRENADE_AMMO > 0)

if(!Prefab || !PrefabSpeed) 

     Debug.Log("Il prefab o la velocità non esiste");
var PrefabCreate = Instantiate(Prefab,GameObject.Find("Projectile Spawn").transform.position,Quaternion.identity);
  PrefabCreate.rigidbody2D.AddForce(transform.forward * PrefabSpeed);
     Collisions.GRENADE_AMMO --;
     GameObject.Find("g_Count").guiText.text = ""+Collisions.GRENADE_AMMO;
     print("YOU NOW HAVE " + Collisions.GRENADE_AMMO + " GRENADES");

Use this:

PrefabCreate.rigidbody2D.AddForce(transform.forward * PrefabSpeed, ForceMode2D.Impulse);

I’m wondering if you are shooting your projectile in the axis that is parallel to your main camera when you need perpendicular if the projectile is behind your 2D character. Try shooting out on the axis that is perpendicular to your main camera view. I don’t know if you want to rearrange your whole scene on a different axis or have your script change the projectiles to go along a different axis when in 3D.

just an offhand thought.

Are you sure that transform.forward is the x-Axis? It should probably be transform.right. Also I suggest you clean this up. If it were any more complex than it is I wouldn’t have read it for its messiness.