- Home /
Changing the Center of a GameObject?
Hey everyone
I made a little Pointer to display velocity on a dashboard. Since it seems that GameObjects always rotate around their Center (duh) i need an advice on how to optimize my script OR how to change the object's center
code :
if(Input.GetKeyDown("R"))
{
transform.Rotate(0, 0, 0*Time.deltaTime);
}
I'm guessing people get this SO EXTREMELY UBER COMPLICATED script :p
thanks..
Biohazard
Answer by Justin Warner · Apr 21, 2011 at 12:17 PM
Well, to change the "center," I assume you mean the pivot point, in which, you'll have to use a 3D program to do that. However, a small work around is make an empty object, then make that object a child of it, and you can use that as the pivot point.
And I don't understand the other thing? Optimize script to do what?
i was wondering if i should EITHER change my object OR my script to make it rotate alright. thanks for the anser, bot how do i actually set the pivot point? my Pointer is made out of a flattened cylinder and a lengthened Cube, so if i attach the rotationscript to the cylinder it'll be fine?
That would be awesome
Answer by h4wkeye · Apr 21, 2011 at 12:32 PM
Nevermind, don't bother answering i found it out :P
Attached the script to my Object and used
Input.GetKey
instead of
Input.GetKeyDown
and called the function in
function Update()
Thanks anyways justin :)
For next time, use the Add Comment below =). I personally couldn't care less, but some people on here hate it when people add a reply as an answer. Just a heads up. And ignore that Bob guy... (He needs anger management, if you look at his past answers sometimes, wow).
Your answer
![](https://koobas.hobune.stream/wayback/20220613124232im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
A node in a childnode? 1 Answer
How to set image in Aspect fit on Texture2D 0 Answers
Collecting game objects in specific order 1 Answer