- Home /
Rigidbody teleports when called AddForce() function
Hello, I am a new C# coder and I am creating a 2d platform game and whenever I call the up arrow key, the AddForce() function is called to my object. But it is not running smoothly, and it is like it is teleporting. I have even called the Time.fixedDeltaTime() but no effect is happening.
Here is the code:
public class playerMove : MonoBehaviour {
public BoxCollider2D box;
public float Yposition;
void FixedUpdate() { Yposition = Input.GetAxisRaw("Vertical");
if (Yposition == 1 && box.IsTouchingLayers(ground)) {
rb.AddForce(new Vector2(0, 100000)*Time.fixedDeltaTime);
}
}
}
Comment
Layer$$anonymous$$ask ground; didn't paste for some reason, still have the same problem.
Your answer
![](https://koobas.hobune.stream/wayback/20220613004502im_/https://answers.unity.com/themes/thub/images/avi.jpg)