I created a script who applies a constant force to the object which is inside my trigger collider. The constant force change if my trigger have a different rotation.
private Transform obj;
void Start(){ obj = GetComponent<Transform>(); }
void OnTriggerEnter(Collider other){
ConstantForce cf = other.gameObject.GetComponent<ConstantForce>();
float rx = obj.rotation.x;
float ry = obj.rotation.y;
float rz = obj.rotation.z;
if (rx==0 && ry==0 && rz==180){cf.force = new Vector3(0f,-1f,0f);} // Up
if (rx==0 && ry==0 && rz==0){cf.force = new Vector3(0f,1f,0f);} // Down
if (rx==90 && ry==0 && rz==0){cf.force = new Vector3(0f,0f,-1f);} // Front
if (rx==-90 && ry==0 && rz==0){cf.force = new Vector3(0f,0f,1f);} // Back
if (rx==0 && ry==0 && rz==-90){cf.force = new Vector3(-1f,0f,0f);} // Right
if (rx==0 && ry==0 && rz==90){cf.force = new Vector3(1f,0f,0f);} // Left
}
My object that is already inside the trigger does not move anymore… What’s the problem?