Rotation an object or character

  • #1, by TinTinSunday, 25. March 2018, 16:32 7 years ago
    Hi

    How can I rotate an object or character in cycle direction?  like this:

    http://uupload.ir/files/nqbb_video_2018-03-25_184657.gif

    Forum Fan

    196 Posts


  • #2, by sebastianSunday, 25. March 2018, 16:36 7 years ago
    do you mean by having a specific anchor point?

    Thread Captain

    2346 Posts

  • #3, by TinTinSunday, 25. March 2018, 16:37 7 years ago
    Yes Sebastian. And rotation drag n drop with mouse

    Forum Fan

    196 Posts

  • #4, by afrlmeSunday, 25. March 2018, 23:17 7 years ago
    function alignChar(c)
     local p1 = Characters[c].CharacterPosition
     local p2 = getCursorPos()
     -- + --
     local ax, ay
     ay = p1.y - p2.y
     ax = p2.x - p1.x
     -- + --
     local angle = math.deg( math.atan2(ay, ax) )
     if angle < 0 then angle = 360 + angle end
     -- + -- 
     c.CharacterDirection = angle
    end

    usage...
    alignChar("Tom")


    This is based on the workflow function I shared on the wiki for aligning one character to another. To make it loop you could register the function as a mainLoop when left click & holding over the character, then unregister on release. I think you could probably make this more global with a bit of editing, but it's late & I'm not in the right frame of mind to figure it out.

    Rotating objects/animations would also be possible as Simon implemented a rotation data stucture parameter for scene objects so you could do the same thing with that, but scene objects require the rotation in radian instead of degrees. I have no idea why.

    Imperator

    7285 Posts

  • #5, by sebastianSunday, 25. March 2018, 23:41 7 years ago
    also keep in mind that the cursor position has to take the scene scroll position in count 

    Thread Captain

    2346 Posts

  • #6, by TinTinMonday, 26. March 2018, 13:18 7 years ago
    Thanks guys and sorry for late answer

    Sorry @AFRLme .I couldn't succeed in your codes yet. I paste your codes in Scripts editor and use  alignChar("MyCharacterName")  in Character actions.
     Where is my wrong?

    Forum Fan

    196 Posts