- Home /
Empty GameObject with box collider randomly rotating itself.
I have a trigger set up using what's in the title, sometimes when objects enter the trigger it rotates itself from 0,0,0 to -125.264,45,0.
I've tried adding a rigidbody to it set to kinematic and also constrained its rotation in X,Y,Z but it's still doing it occasionally.
any suggestions?
I have void OnTriggerExit(Collider other) which is the main part of the script that's attached to it, After taking another look I do have a function inside the same script which is instantiating a prize and setting its rotation. It does appear the trigger is rotating the same as the prize.. Quaternions still really confuse me if you think that I'm doing it wrong and have any tips? I don't see how setting a rotation in an instantiate is affecting the object the script is attached to. Instantiate(prizes[Random.Range(0, prizes.Length)], SpawnLocation.transform.position, transform.rotation = Quaternion.Euler(-90, 0, 0));
Answer by Divinitize1 · Jun 11, 2019 at 08:01 PM
I had a function inside the script which instantiated a random object, for some reason the rotation in the instantiate was also rotating the trigger box. I think i had an error in my code
This was causing the Issue. transform.rotation = Quaternion.Euler(-20, 90, 0)); And this was the fix transform.rotation * Quaternion.Euler(-20, 90, 0));
Your answer
Follow this Question
Related Questions
OnTriggerEnter2D randomly stops detecting 1 Answer
Switch Vector3 direction 1 Answer
Camera rotation around player while following. 6 Answers
Smoothly rotate Quaternion using random range 1 Answer
OnTriggerEnter smooth Rotate 1 Answer