- Home /
help with code for changing an objects rotation?
So, I basically was wondering if anybody could help me with making a code so that when I push and hold a particular key down, an object in the scene changes its rotation and position? Any help is appreciated :)
Answer by Jean-Fabre · Mar 21, 2011 at 09:03 AM
Hi,
You'll find this answer and forum reply with fully working project maybe useful:
But, I have to agree with Bodaebob, have a go at it yourself first, this far more lucrative as a learning experience, then come up with question where you have problems in your code.
Bye,
Jean
Answer by AngryOldMan · Mar 19, 2011 at 11:01 PM
I suggest having a go at it yourself because people here will not just make code for you when you please. This is for problems you are having when creating something in Unity, you should start by creating something then if you have a problem post a detailed question here. In the meantime take a look at unity script reference site for transforming an object http://unity3d.com/support/documentation/ScriptReference/Transform.html pay attention to transform.postition and transform.rotation (or eularAngles) and also http://unity3d.com/support/documentation/ScriptReference/Input.html for inputs.
I wasn't meaning to sound like I was asking somebody to write a code for me, I was actually more wondering if somebody could give me a general direction to go in.
well you shouldn't have said "I basically was wondering if anybody could help me with making a code" and not made an effort in the 1st place. If you have said "Does anyone know how I should go about ..." then I would have given the same answer but without the snappy comments.
Your answer
![](https://koobas.hobune.stream/wayback/20220613113742im_/https://answers.unity.com/themes/thub/images/avi.jpg)