Invisible walls bouncing my character?

I have a little issue that is likely easily resolved, but I just can’t figure out the proper way to deal with it. I’ve created a couple of visible walls that merely consist of two box colliders. The issue I’m having is that whenever my character collides with them, he bounces off and wont stop moving. My character is not using any of the built in controllers, which may or may not be the problem… Both my character and the walls have their gravity turned off ( my character is flying forward constantly). My character has a rigid body because it’s needed for another effect in the game… he has a collider as well… I’m wondering if the character controllers have some built in scripting that keep characters from bouncing, and if that’s the case I could switch, but I was just wondering if there’s any simple fix to keep my character from getting bounced around when his collider collides with another nontrigger collider.

I’m still having trouble with this. I’ve tried a few different things. I tried freezing the player characters position and rotation in the rigid body, but if I freeze the position he just gains the ability to pass right through the invisible wall’s box collider for some reason. It’s strange because I’ve seen invisible walls in tutorials and whatnot, and from what I can tell there’s no difference between their walls and mine. The only difference I can think of is that they are using the built in player controller (either third or first) whereas I am not. Does anybody know if there’s some code in that that keeps your character from bouncing off of colliders? I’ve taken a peek at it and didn’t notice anything… I tried creating a script that sets the characters velocity to 0 if it collides with an invisible wall, but it also just allowed my character to pass through the wall -.-'… the only thing I can think of at this point is to have it force the Z position of the character to be set to the position it is at the moment it collides, every time it collides… I was just hoping there was a different way that would just get rid of all the unnecessary physics calculations in general :confused:

Alright, so I came up with this solution, just in case anyone else ever has this problem and finds this thread via search.

First the walls have to be thicker than 1 unit, I set the x thickness to 10 because the X was equal to my wall’s width. Otherwise my guy can glitch through them. I leave the physics as is, with rigid bodies on an whatnot, except I freeze the rotation of my characters rigid body along the x, y, and z, and then also freeze its position along the y and z (the direction your character collides with this from should not be frozen). Give the invisible walls a tag to identify them with, I used InvisWalls as seen below. I then added the following code to the script attached to my player character:

function OnCollisionExit(collision : Collision) {
	if(collision.gameObject.CompareTag("InvisWalls")){
		
		rigidbody.velocity = Vector3(0,0,0);

	} 
}

And that’s it. My character still bounces of the wall a little bit, but at least he doesn’t fly in that direction infinitely. Still seems like a waste of resources (albeit a very small waste) to calculate the bounce at all, but whatever.