- Home /
Rotate with script and point
I have a script that when I click on a button, I move a project to the right place, I need to immediately after he has transmuted it turned around by 30 degrees in x on the red dot, what is the best way to do this?
Answer by DCordoba · Jan 26, 2019 at 10:35 PM
um I think to RotateAround is what you need.
public Vector3 redDotPos;// on global pos
transform.RotateAround(redDotPos,30f ,Vector3.up);
if you want to change position of the square, you'll need the redDotPos relative to the main center of the quad, so on local position
//on local pos, relative to the center
public Vector3 redDotPos;
//convert to global
Vector3 globalDotPos = transform.position + (transform.forward * redDotPos.y +
transform.right * redDotPos.x -
transform.up * redDotPos.z);
transform.RotateAround(globalDotPos, 30f ,Vector3.up);
here's a mistake Assets/$$anonymous$$ainSkripts/TriggerTest.cs(17,27): error CS1502: The best overloaded method match for `UnityEngine.Transform.RotateAround(UnityEngine.Vector3, UnityEngine.Vector3, float)' has some invalid arguments
yep I mistake the order of arguments, sorry there is the correct way
transform.RotateAround(globalDotPos, Vector3.up, 30f);
No, everything solved the problem! Now the problem is that the model starts to distort itself
I mistake a $$anonymous$$us... is
Vector3 globalDotPos = transform.position + (transform.forward * redDotPos.y +
transform.right * redDotPos.x +
transform.up * redDotPos.z);
but thats not the cause, thats probably because each axis of the parent scale haven't the same dimension
you need to redo the parent scale to keep proportions
Your answer
![](https://koobas.hobune.stream/wayback/20220612190530im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
how to scale the transport? 1 Answer
problem with rigidbody.position 1 Answer
How to manage an object using joints? 0 Answers
problem with wheelcollider 0 Answers
How to make the same scaling of sub-projects during export? 0 Answers