I want to create a 2d clicker game, where you launch the player forwards to destroy walls. I have two problems right now: I dont know how to calculate the rb.AddForce so, that it always hits the wall with one click (If I increase the force, the player gets launched far back because of the physics material or he glitches through the wall). My second problem is, that I dont know how to get the player smoothly in his exact original position after he hits the wall. It sounds very wierd but I hope that you can Imagine what I want to create…
This is the Project right now: https://streamable.com/76dujj
Thats my code:
public Rigidbody2D rb;
public float force;
void Start()
{
rb = GetComponent<Rigidbody2D>();
}
void Update()
{
if (Input.GetMouseButtonDown(0))
{
TouchAttack();
}
}
void TouchAttack()
{
rb.AddForce(Vector2.right * force, ForceMode2D.Impulse );
}
}