Object has wrong rotation when following path

  • Hello there
    I'm doing a small scene with a boat following a path. The boat has the right direction before pressing play, but when pressing play, it rotates the object 90 degrees, despite how I rotate the boat in my maya file.
    So I can't get it to face forward.
    What am I doing wrong? :)

    Any direction would be much appreciated
    Cheers, Dan

  • Thanks for joining the forums.

    The cause is that your model has a different "forward" rotation than the movement script / Unity is expecting. I'm not sure about Maya, but in Blender the object rotation needs to be "applied" to the model, for it to have any effect in Unity. Ultimately you have two options:

    • go back in your modelling application and rotate the model there, or
    • create a new gameobject in Unity, attach the movement script to this new gameobject and make your object a child of it. The movement script will now move the parent instead of your (child) model directly, so you can now rotate the child to the desired rotation.

  • @Baroni Me again. I haven't yet posted my (5*) review of SWS yet because you haven't rolled out your GetPathPoints reference fix in BezierPathManager. I don't want my review to say "on previous version 5.4.5" beside it.

    Anyroad I am bringing back this old thread because it would be useful if you could let me know where the code that rotates the object to the path is.

    SWS (+ DOTween) makes objects rotate to paths, ergo it could easily make them rotate to paths facing backwards, or 90 degrees left or whatever, with a tweak.

    Keep up the good work.

  • Regarding the fix, I do not roll out new versions containing single fixes. Every time a new version is uploaded is takes up to 2 weeks for the Asset Store team to approve it, also displaying a popup to all users on approval. Fixes are combined into a version that makes sense to release it. The reason we set up this forum like this (with only members able to see code) is specifically to share smaller fixes without the need to release tiny updates.

    The rotation code is not done by SWS. Because of that, unfortunately I am not able to tell you where the code for that is - the rotation is done by DOTween, internally.

  • @Baroni Right. And Daniele Giardini hides most of his code in DLL files. :(

    Actually, just in case anyone else searches and finds this: the OP had a 3DS Max problem. The answer is: select object, Hierarchy panel > Pivot button > Adjust Pivot rollout. Push "Affect Pivot only". Rotate X axis by 90 degrees, so that Y [Green arrow] pointing up. Then models aren't all lying down on import.

  • It depends on what you're using as an "up" axis in your modelling application, but that's basically what I meant with the point above:

    • go back in your modelling application and rotate the model there

    E.g. in Blender there's a different "up" orientation one has to apply the rotation to before exporting.

Log in to reply