Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Cannot rotate object

Discussion in 'Scripting' started by Eiseno, Jan 5, 2020.

  1. Eiseno

    Eiseno

    Joined:
    Nov 1, 2015
    Posts:
    86
    Hello my object fallow a path. So when it follows path I want it to rotate same direction with paths current point. But also when its moving I want to it rotate around itself with its own velocity. If I only write Rotate funcion line my object rotate around itself correctly. But If I try to rotate around and follow path rotation same time it doesn't work. I tried many things but it doesn't work. Can someone tell me my problem.



    Code (CSharp):
    1.  var pointRotation =
    2.                 _currentPath.GetRotationAtDistance(_currentPath.GetClosestDistanceAlongPath(screws[i].position));
    3.          
    4.              screws[i].rotation = Quaternion.Euler(pointRotation.eulerAngles.x, pointRotation.eulerAngles.y,
    5.                0);
    6.             screws[i].Rotate(0, 0, rotateVelocity, Space.Self);
    Best Regards
     
  2. Yoreki

    Yoreki

    Joined:
    Apr 10, 2019
    Posts:
    2,605
    How would you, at the same time, rotate around yourself and follow the rotation of some path? Are you talking about different axis, like rotating around the z-Axis, while following the rotation of some path on the y-Axis? Doesnt seem like what you are doing with your code tho.
     
  3. Eiseno

    Eiseno

    Joined:
    Nov 1, 2015
    Posts:
    86
    my screw needs to rotate around itself at Z axis and follow path rotation at X and Y axis @Yoreki