- Home /
How to programmatically rotate 2D GameObject with SliderJoint2D Attached
I have a Game Object with SliderJoint2D attached. Now I am trying to rotate the object using :
rigidbody2D.MoveRotation(rigidbody2D.rotation + rotationSpeed * Time.deltaTime);
Everything works correct, no errors, no warnings, but when I press the button GameObject does not rotate when Slider Joint is attached. When I try the same code with slider joint disabled, it works, but the problem is that I need my object to slide vertically.
I also tried to disable slider joint and keep my object sliding using this code:
Vector3 tmp = transform.position; tmp.x = 0; transform.position = tmp;
But in this case I am getting horrible problem with my wheel joints they just start to move in a very crazy and abnormal way.
You are welcome to suggest solutions for both cases: Or how to rotate object with slider joint, Or How to fix the wheel joints crazy movement.
Thank you in advance! :)
Your answer
![](https://koobas.hobune.stream/wayback/20220613172655im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Rotate object without rotating RayCast 4 Answers
Rotate Clicked Gameobject / Perhab 0 Answers
Rotate gameobject on Y axis 1 Answer
Transform.rotation problems 1 Answer