- Home /
Altered Collider parameters when Using Euler
var spark : GameObject;
private var counter=0;
private var grav = 0;
private var targetRotation : Quaternion;
function Start(){targetRotation=transform.rotation;}
function Update () {
if(grav!=counter){
targetRotation=Quaternion.Euler(targetRotation.eulerAngles.x,targetRotation.eulerAngles.y,targetRotation.eulerAngles.z-90);
//targetRotation *= Quaternion.Euler(0,0,-90);
grav=counter;
}
switch(counter){
case 1:camera.main.GetComponent(Data).GlobalGravity = Camera.main.transform.right;
break;
case 2:camera.main.GetComponent(Data).GlobalGravity = Camera.main.transform.up;
break;
case 3:camera.main.GetComponent(Data).GlobalGravity = Camera.main.transform.right*-1;
break;
default:
camera.main.GetComponent(Data).GlobalGravity = Camera.main.transform.up*-1;
}
transform.rotation = Quaternion.Slerp(transform.rotation, targetRotation, Time.deltaTime*2);
}
function OnCollisionEnter(collision : Collision){
if(collision.collider.tag == "Projectile"){
Instantiate(spark,collision.contacts[0].point,transform.rotation);
//if(counter<3){
counter++;
}
//}
}
Okay so the player shoots the arrow and changes gravity then rotates to point in the correct direction.Everything works fine except for the rotation part, which means I mark off the rotation code and shot it up and this glitch didn't happen. After two collisions the collider is set dramatically bigger to the side of the object.After 3 collisions the collider is stretched out diagonally across the whole stage(stupid invisible wall). I know it's the arrow collider because it's the only thing that makes sparks when you shoot it in the scene.When I pause the game to look at the collider it's a nice little capsule shape right where it should be. The arrow model(no collider) is a child of an empty game object with the collider component. The picture is a little misleading because the pivot point is in the center of the arrow instead of above it. I've use this code- targetRotation *= Quaternion.Euler(0,0,-90); , many times before with no problem, so please any help would be appreciated.
Answer by Josh Wilson · Feb 10, 2011 at 07:15 PM
Weird, found out that giving an empty gameobject a capsule collider then using Quaternion.Euler is a big No No. Maybe it warps the collider all out of whack because the Empty gameobject doesn't have a necessary component like a renderer to anchor the collider to even though it's a component to the Empty gameobject. My version of unity is a version behind however so maybe it's fixed in the newest version. Anyways got rid of the empty gameobject parent and now it work fine again. Still find it odd.
Your answer
![](https://koobas.hobune.stream/wayback/20220613103614im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Reverse Rotation on mesh collision 1 Answer
Rigidbody doesn't rotate after collision 3 Answers
Character Controller falls through moving/rotating platforms (Not A Duplicate Post) 1 Answer
Odd collider rotation 1 Answer
Get angle from impact 2 Answers