I have an enemy with 4 empty gameObjects as children - one in front, back, and each side. I use those to detect where he is in relation to an explosion so it triggers the appropriate animation and adds force in the correct direction. The script works fine in that all the correct animations are triggered, and when I addforce front and back the character will fly away from the explosion. But when the explosion is to either side of him, the animation triggers but he doesn’t go anywhere. Everything is identical in the script except for the addForce. i have trid changing the drag and the AddForce thrust but to no avail. Here is the portion of the script where this stuff happens. Anyone see any reason it isn’t working for left and right like it does for forward and back?
void FixedUpdate(){
if (Vector3.Distance (transform.position, target.position) <= boomDistance && boom == false) {
if (lowestValue == R) {
agent.enabled = false;
rb.isKinematic = false;
newDrag =9f;
rb.AddRelativeForce (Vector3.left * thrust);
Right ();
StartCoroutine (DelayAfterIK ());
}
if (lowestValue == L) {
agent.enabled = false;
newDrag =10f;
rb.isKinematic = false;
rb.AddRelativeForce (Vector3.right * thrust);
Left ();
StartCoroutine (DelayAfterIK ());
}
if (lowestValue == B) {
agent.enabled = false;
newDrag =30f;
rb.isKinematic = false;
rb.AddRelativeForce (Vector3.forward * thrust);
Back ();
StartCoroutine (DelayAfterIK ());
}
if (lowestValue == F) {
agent.enabled = false;
newDrag =30f;
rb.isKinematic = false;
rb.AddRelativeForce (Vector3.back * thrust);
Forward ();
StartCoroutine (DelayAfterIK ());
}
}
}