- Home /
why is one side of collider behaving different than the other
there's two game objects in question here. the ship(player) and the bouncer(wall that acts like a rubber barrier).
here's the script that makes the wall bounce the ship backwards.
function OnTriggerEnter (other : Collider){
if (other.name == "Ship"){
Repel (other.gameObject);
}
}
function Repel (other : GameObject){
var shipRepelSpot = other.transform.position + transform.TransformDirection(Vector3(-3, 0, 0));
iTween.MoveTo(other, shipRepelSpot, 0.8);
}
basically what's happening is when the ship hits on side of this bouncing wall, it gets repelled properly. On the other side, however, the ship kinda squeezed through the wall in an awkward motion. I just want to know why would one side be behaving differently on the same object. I've checked the collider size. The ship/player is the trigger and has a rigidbody, the bouncing wall just has a collider.
Have you checked that shipRepelSpot is on the side of the rubber wall that you expect it to be on for both cases?
Answer by wknight92 · May 14, 2012 at 06:18 PM
var shipRepelSpot = other.transform.position + transform.TransformDirection(Vector3(-3, 0, 0));
needed to be changed to
var shipRepelSpot = other.transform.position + other.transform.TransformDirection(Vector3(-3, 0, 0));
That doesn't make much sense ;) his script is on the wall, not on the ship and he wants the direction relative to the wall, not relative to the ship.
Btw, this:
transform.TransformDirection(Vector3(-3, 0, 0));
is the same as
transform.right * -3;
Answer by Berenger · May 14, 2012 at 05:25 PM
You're not using physic for the repulsion, only for the collision detection. The side isn't relevant then.
However, I guess that the two walls are facing the same direction / have the same rotation. Which means that transform.TransformDirection will point inside for one, outside for the other.
Rotate the incorrect wall of 180 on Y.
The other way would be to make the direction vector configurable, so you can just remove the "-" in the inspector ;)
Your answer
![](https://koobas.hobune.stream/wayback/20220613071458im_/https://answers.unity.com/themes/thub/images/avi.jpg)