- Home /
Question by
Beanmeister12 · Mar 10, 2018 at 01:34 AM ·
c#vector2collision2drigidbody.addforce
Trying to apply force to an object
I'm trying to apply force to an object in the opposite direction of a public Vector2, although I don't know what to put after the AddForce. I tried (-velo) but it didn't do anything. Thanks for any help!
public Vector2 velo;
void OnCollissionEnter2D (Collider2D col) {
if (col.gameObject.tag == "ground") {
GetComponent<Rigidbody2D> ().AddForce ();
}
}
void Update () {
velo = GetComponent<Rigidbody2D> ().velocity;
}
Comment
Answer by EnigmaticCrow · Mar 10, 2018 at 04:44 PM
Your function OnCollissionEnter2D never gets called because it needs to be OnCollisionEnter2D (only one s).