Help! rotation based on distance between initial touch X and swipe X distance from the initial touch

jay2dxjay2dx Member Posts: 611

Hi everyone,

hoping i can get some help with this, as the title says I'm having a hard time setting up an actors rotation based on the initial touch and swipe distance from the initial touch.

i have it working to an extent but, the actors rotation, spins about on the next initial touch, basically its constrained to the magnitude between the initial touch x and the mouse position x

what i want to achieve is a rotation that increases in increments from the initial touch position. and on the next touch it doesn't jump about its rotation, but continues smoothly from its rotation again from the initial touch. hope that makes sense?

i guess i need to tell the actors to rotate based on the magnitude from the initial touch but in a way that only increases the rotation, not constraining it to the rotation of the distance via magnitude. I'm thinking i need to set up some code to tell it to ad too its rotation based on the magnitude, i just don't know how.

hope some one can help :)

Comments

  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,879

    Try something like this:

    When mouse is down  
      Change Attribute: self.startingX To: self.Position.X
      Change Attribute: self.startingRotation To: self.Rotation
      Constrain Attribute: self.Rotation To: self.startingRotation + (self.startingX -game.mouse.Position.X)
    
  • jay2dxjay2dx Member Posts: 611

    @RThurman thanks man, will give it a shot sounds like that will work :)

  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,879

    You are welcome. Hope it works for you.

  • jay2dxjay2dx Member Posts: 611

    Thanks for the help @RThurman but it still jumps about its rotation on initial touch, I have a temporary solution using angular volosity buts it's not perfect as it's not based on distance from initial touch and it keeps rotating anyways will upload a demo sto show what I'm getting at if anyone cares haha :)

  • KevinCrossKevinCross London, UKMember Posts: 1,894
    edited May 2016

    Like this?

    There's some old attributes in there from a project I'm working on with this in it so ignore those. You can see what's needed from the one actor in the project

    https://www.dropbox.com/s/1k34figdx38kx3l/Drag To Rotate Box.zip?dl=0

    Sorry I can't attach projects as my account has temporarily expired

  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,879

    @jay2dx said:
    Thanks for the help @RThurman but it still jumps about its rotation on initial touch, I have a temporary solution using angular volosity buts it's not perfect as it's not based on distance from initial touch and it keeps rotating anyways will upload a demo sto show what I'm getting at if anyone cares haha :)

    Hmm... Here is a demo that shows one way to do it.

    (I like @KevinCross's suggestion better!)

  • KevinCrossKevinCross London, UKMember Posts: 1,894

    @RThurman said:

    @jay2dx said:
    Thanks for the help @RThurman but it still jumps about its rotation on initial touch, I have a temporary solution using angular volosity buts it's not perfect as it's not based on distance from initial touch and it keeps rotating anyways will upload a demo sto show what I'm getting at if anyone cares haha :)

    Hmm... Here is a demo that shows one way to do it.

    (I like @KevinCross's suggestion better!)

    I can't take credit for it. I would have only found it here on the forums

  • jay2dxjay2dx Member Posts: 611

    Thank you guys so much for the help, will try these out and report back, what a great community here hey! :)

  • jay2dxjay2dx Member Posts: 611

    thanks guys, both methods work great, ill probably include them both with an option to choose so thank you :)

  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,879

    Glad they are working for you!

Sign In or Register to comment.