Login / Registrieren
DE EN FR ES IT CZ
Zurück Nach oben

Rotation an object or character

  • #1, by TinTin 8 years ago Zitieren
    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
  • #2, by sebastian 8 years ago Zitieren
    do you mean by having a specific anchor point?
  • #3, by TinTin 8 years ago Zitieren
    Yes Sebastian. And rotation drag n drop with mouse
  • #4, by afrlme 8 years ago Zitieren
    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.
  • #5, by sebastian 8 years ago Zitieren
    also keep in mind that the cursor position has to take the scene scroll position in count 
  • #6, by TinTin 8 years ago Zitieren
    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?