- Home /
Character controller Rotate around the object
Hi everyone.
I want my character to rotate around a point(origin) when Horizontal input is applied. And I also want the character controller component.
With transform.RotateAround I can rotate gameobject except with the one with character controller. So for temporary fix in Update I disable the character controller component rotate with transform.RotateAround and then again enable the component.
I know this is not the best way to solve this problem. I hope some one can help me.
Hi, not sure I understand your question regarding the character controller. Also it would be easier to see what you're trying to do if you post the relevant code
void Update()
{
float x= Input.GetAxis(“Horizontal”);
controller.enable=false;
transform.RotateAround(Vector3.zero,Vector3.Up,x *speed*Time.deltatime);
controller.enable=true;
}
Answer by Cassos · May 02, 2020 at 05:54 PM
Make the controller a child of an object you place where you want as a pivot. Then you rotate the parent.
Thanks a lot it help me out. Idk why I didn’t think of it this way. Thanks again
Answer by Z-ion · May 03, 2020 at 04:28 PM
@Cassos You solution was correct but I want to rotate character when horizontal input is given and move forward and backward when vertical input is give. I make the character controller child and when I move the character horizontal it works and when when I give vertical input the child moves and parent stay at the position.