Continuously moving rigidbody

Hello, I’m back again asking a second question for my 2D game, wondering why my rigidbodies are stopping and how to to keep them moving around the field/randomly at all times. Basically, I have a rigidbodies that spawn at a random location and have a vector force applied to them at start to begin the moving motion. These rigidbodies are not kinematic and no gravity is enforced. To keep them within bounds, I have added pairs or box colliders around the borders of the game. One collider in each pair acts as the actual wall/boundary with an attached physic material with a bounce factor of 1 and no friction. The second collider in a pair has a script the adds a force to all objects that enter it’s trigger in order to keep the object moving around the screen.

The problem is that these rigidbodies slow down and eventually stop responding to my script or to it’s rigidbody component at some point. The object should continuously move around the playing field at random, but it eventually slows down and gets stuck in a corner. Sometimes, the gameObject noticeably slows down after a certain time which is why it could be a rigidbody component issue, however newly spawned gameObjects stop reacting to the boundaries as well so I’m not sure if it’s a scripting issue.

Here’s the script attached to the game boundary colliders:

using UnityEngine;

using System.Collections;

using System.Collections.Generic;



public class ScriptWindArea : MonoBehaviour

{
	
	public List<GameObject> AffectedObjects;
	
	public Vector3 ForceVector;
	
	
	
	void OnTriggerEnter(Collider collidee)
	
	{
		if(collidee.gameObject != null || collidee != null)
		{
			if(collidee.gameObject.tag != "Enemy")
			{
				AffectedObjects.Add(collidee.gameObject);
			}
		}
	}
	
	
	
	void OnTriggerExit(Collider collidee)
	
	{
		if(collidee.gameObject != null || collidee != null)
		{
			if(collidee.gameObject.tag != "Enemy")
			{
				AffectedObjects.Remove(collidee.gameObject);
			}
		}
	}
	
	
	
	void Update()
	
	{
		
		for(int I =0; I < AffectedObjects.Count; I++)
		
		{
			if(Time.timeScale > 0)
			{
				try
				{
					AffectedObjects*.rigidbody.AddForce(ForceVector);*
  •  		}*
    
  •  		catch*
    
  •  		{*
    
  •  			return;*
    
  •  		}*
    
  •  	}*
    
  •  }*
    
  • }*
    }
    Could someone explain to me the right way to make sure a gameObject is continuously moving through the playing field, or explain to me why my script/gameObjects are not functioning properly?

do your rigid bodies also have a physics material attached or just the walls?

I forgot to update this question as I have fixed my problem myself by adding a call to remove the missing gameobject in my catch statement like this:
try
{
AffectedObjects*.rigidbody.AddForce(ForceVector);*
}
catch
{
AffectedObjects.Remove(AffectedObjects*);*
return;
}