Hey, I’m making a little simulation with the idea to add very basic machine learning. There are 2 robots: red and blue robots. These robots have different modes, one of them is meleeMode. In meleeMode they can attack eachother from a very close distance. The attack itself should push the robot backwards with “AddRelativeForce(vector3.back * bounceback, forceMode.impulse)” and the robot does go backwards, but it keeps bouncing upwards. I tried using physics materials to fix this, but it didn’t work. Does anyone know how to fix this?
private void OnCollisionEnter(Collision collision)
{
if (collision.gameObject == otherCube && mode == Modes.melee)
{
Debug.Log(collision.gameObject.name + " bang");
collision.gameObject.GetComponent<Nav>().happiness -= 4;
if (red)
redHappinessAvg -= 4;
else
blueHappinessAvg -= 4;
//cube.enabled = false;
cubeRb.AddRelativeForce(Vector3.back * bounceBack, ForceMode.Impulse);
}
}