- Home /
Rotate an object to a given point
How can you turn the project to a given point when you press a key, while the point (1) always hits its place. To point (1) there is a tuned pivotalt text
Answer by xxmariofer · Jan 23, 2019 at 10:29 PM
Thats just not rotating the object, since you have to also move the transform, the easiest and most common (although not the best practice) approach is to create a empty object drag the object you want to assign in there and rotate the new parent object rather than the child, then just offsetting the child will give you your desired rotation.
Thanks for the answer, but this is not it! I have a script where when I click on an object it moves to the point of the parent object, but I need it so that it doesn’t beat, but the beat is turned as in a picture!
i am pretty sure he just needed what i told him, it is short of a hack but works fine.
using this code and offseting the child
Vector3 vector = Vector3.RotateTowards(transform.rotation.eulerAngles, target, speed, speed);
transform.rotation = Quaternion.Euler(vector);
Answer by mlnczk · Jan 24, 2019 at 02:26 PM
If above advises doesnt help you. You can always DOTween. Its free asset very easy to use. Its a good replacement for easy animations and way more optimised. You can call a method that will rotate/move object to whatever value you want easily. Here is link: https://assetstore.unity.com/packages/tools/animation/dotween-hotween-v2-27676?aid=1101lSqC&utm_source=aff
Good ! Thanks for the answer ! I'll try and this method =)
Your answer
Follow this Question
Related Questions
How to turn the steering wheel 0 Answers
How to assign a rotation relative to another object? 2 Answers
problem with object rotation 1 Answer
turning a project using AddTorque 0 Answers
what are the ways to attach objects 1 Answer