Menu
Login
Language
DE EN FR ES IT CZ
Back

Rotation an object or character

  • #1, by TinTin Sunday, 25. March 2018, 16:32 8 years ago Quote
    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 sebastian Sunday, 25. March 2018, 16:36 8 years ago Quote
    do you mean by having a specific anchor point?

    Thread Captain

    2346 Posts

  • #3, by TinTin Sunday, 25. March 2018, 16:37 8 years ago Quote
    Yes Sebastian. And rotation drag n drop with mouse

    Forum Fan

    196 Posts

  • #4, by afrlme Sunday, 25. March 2018, 23:17 8 years ago Quote
    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

    7290 Posts

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

    Thread Captain

    2346 Posts

  • #6, by TinTin Monday, 26. March 2018, 13:18 8 years ago Quote
    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