Can't seem to get AddForce to work for me.

Hello all. I’m very new to Unity and C#, so most of my scripting is just trying to adapt code that I find in tutorials or the web. My first game has a ball that I’m trying to add a forward force to, like it was hit with a steam blast from behind. I’ve tried a few different ways, but it nothing seems to work like I need.

I have an EdgeCollider2D that acts as a trigger for the blast, and this is the code I’m trying:

public class SteamBlast : MonoBehaviour {

	public Rigidbody2D rb;

	void OnTriggerEnter2D(Collider2D other) {
		rb.AddForce(transform.forward * 100);		

I can actually get it to work if I change the last line to this:

rb.transform.Translate(new Vector2(-1,-1) * 100f * Time.deltaTime); 

but it does not have exactly the desired effect, and I don’t want to have to change the vector every time I want it to happen.

Thanks for looking.

I think your problem is that transform.forward is a Vector3 (0, 0, 1)
and if your game is 2D it will not work.
Instead try to set the vector manually like this:
rb.AddForce(new Vector2(0, 1) * 100); // depending on if u want to apply force on x or y

I hope I helped