Unity OnCollissionEnter() is not working.

Hi,
I have this weird issue even though I am Getting Debug my code is not working.
Also Note that it is not working only for my machine for whether its editor or build, it is working well in every other computer.
Here is my code Though.
I am getting logs very well its just not transforming position.

public void OnTriggerEnter(Collider other)
{
Debug.LogError("General collider detected " + other.gameObject.name);
if (other.gameObject == GameManager.Instance.LocalObject && chek)
{
Debug.LogError(“Our Local Player Detected”);
if (this.gameObject.name == “PortalTunnel collider 1”)
{
Debug.LogError(“Game Object Transform entered from 1”);
GameManager.Instance.LocalObject.transform.position = TransformLocation2.transform.position;
GameManager.Instance.LocalObject.transform.rotation = TransformLocation2.transform.localRotation;
}
if (this.gameObject.name == “PortalTunnel collider 2”)
{
Debug.LogError(“Game Object Transform entered from 2”);
GameManager.Instance.LocalObject.transform.position = TransformLocation1.transform.position;
GameManager.Instance.LocalObject.transform.rotation = TransformLocation1.transform.localRotation;
}
// IsOtherCameraOn.SetActive(false);

}
}

If you post a code snippet, ALWAYS USE CODE TAGS:

How to use code tags: https://discussions.unity.com/t/481379

You may edit your post above.

With Physics (or Physics2D), never manipulate the Transform directly. If you manipulate the Transform directly, you are bypassing the physics system and you can reasonably expect glitching and missed collisions and other physics mayhem.

Always use the .MovePosition() and .MoveRotation() methods on the Rigidbody (or Rigidbody2D) instance in order to move or rotate things. Doing this keeps the physics system informed about what is going on.

https://discussions.unity.com/t/866410/5

With a wheel collider, use the motor or brake torque to effect motion.

You seriously want to avoid this kinda hairy code:

If you have more than one or two dots (.) in a single statement, you’re just being mean to yourself.

How to break down hairy lines of code:

http://plbm.com/?p=248

Break it up, practice social distancing in your code, one thing per line please.

1 Like

Thank you for exact solution and I did not know about this detail about MovePosition and I agree with dots However it was fast run project with short deadline I also agree I don’t have habit to use code like that so I am glad you acknowledge that hence will work on that.

After Checking it again I am using character controller and no Rigidbody.

Then you should go review the specific requirements to receive the calls you expect, such as OnTriggerEnter.

Hint: there needs to be a Rigidbody involved somewhere

I am Using Photon and 3pp newInput character controller https://assetstore.unity.com/packages/essentials/starter-assets-third-person-character-controller-196526
also what I am saying is, It is working in every other PC but not in my particular PC in WebGL and Editor. Also Note that my PC is much high end I9 10900k , 32GB RAM 3600Mhz, 3070 Graphic card is it if there is something related to too much FPS(Overclocking) I don’t know.