# Unity BoxCollider2D causes motion to be exponentially multiplied

I have a player and an enemy square for my 2D game (technically it's a cube, but it's rendered as a 2D character). I have a RigidBody2D attached to the player and the enemy each, along with a BoxCollider2D, with trigger ticked on both of them. However, when I untick trigger the motion gets multiplied drastically. It appears to be that the trigger being ticked is causing the entire thing to be updated more quickly but I'm not sure. Can someone help?

FIX I needed to turn off Auto Mass in the Rigidbody2D. Thanks @DMGregory

Enemy Code:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class enemyController : MonoBehaviour
{

public GameObject player;
public GameObject graphicsGameobject;

public int movementSpeed;
public float fireRate;

// Private Refrences
new private Rigidbody2D rigidbody;

// Start is called once
void Start() {
rigidbody = GetComponent<Rigidbody2D>();
}

////////////
// MOTION //
////////////

// Return position to face player
Vector2 getMouseVector()
{
// Get mouse pixel position, convert it to world position, subtract
// from current position vector to get angle, and return as negative Vector2
// Why negative?  Only way I could get it to work.
Vector2 myPosition = transform.position; // V3 converted to V2, that's why this line exsists
return -(myPosition - new Vector2(
player.transform.position.x,
player.transform.position.y
));
}

// Move the player's RigidBody to chase player
void moveEnemy() {
Transform ptrans = player.transform;
if (ptrans.position.y > transform.position.y) // Up
{ rigidbody.AddForce(transform.up * movementSpeed * Time.deltaTime); }
if (ptrans.position.x > transform.position.x) // Left
{ rigidbody.AddForce(transform.right* movementSpeed * Time.deltaTime); }
if (ptrans.position.y < transform.position.y) // Down
{ rigidbody.AddForce(transform.up * -movementSpeed * Time.deltaTime); }
if (ptrans.position.x < transform.position.x ) // Right
{ rigidbody.AddForce(transform.right * -movementSpeed * Time.deltaTime); }
}

////////////
// UPDATE //
////////////

void Update() {
graphicsGameobject.transform.up = getMouseVector();
moveEnemy();
}

}

• Are you calculating the mass of the body using its colliders? Trigger colliders might not be counted for this purpose, which could change how the inertia of the body is initialized. – DMGregory Jan 14 '20 at 19:30
• I’m calculating mass with the Rigidbody2D, and i could be with the Collider also. I’ll check. Thanks! – get_scripted Jan 14 '20 at 19:43
• It was the auto calculated mass in the Rogidbody2D. Thank you @DMGreogory! – get_scripted Jan 14 '20 at 20:09
• Sweet! Please post that as an answer so it's easy for future users to find. – DMGregory Jan 14 '20 at 20:36