How do I make an object rotate to another object.?

0 favourites
  • 7 posts
From the Asset Store
Hand-painted tiles, objects, animated objects, and background to build a colorful Mayan civilization environment.
  • Hello. I am trying to make an object "on drag" rotate from it's pivot point. So how I went about it so far is...

    1. I created my "draggable" object and gave it a clamp value of 100,300 on the vertical axis. that works fine. But when I drag this object, I want another object to rotate according to the drag value a certain amount of degrees. (ex: between 20d and 360d).

    Is there a way to "map" a range from an object to another object. EX: range 100,300 to angle 20, 360?

    If not, then I have to find where in the range of my dragged object I'm at, convert it to a percentage, then do the same math on my rotating object, correct?

    Thx!

    Marc.

    Tagged:

  • Set angle to clamp(lowerbound,angle(self.x,self.y,target.x,target.y),upperbound)

    IIRC, angle() returns a value between -180 and 180 with 0 facing right, so take that into account when setting your lower and upper bounds.

  • F-O-U-N-D I-T!!!

  • Set angle to clamp(lowerbound,angle(self.x,self.y,target.x,target.y),upperbound)

    IIRC, angle() returns a value between -180 and 180 with 0 facing right, so take that into account when setting your lower and upper bounds.

    Thanks!!! will try that as well.

  • Oh right, if you want a slider to aim rather than a direct target, lerp will work much better.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • i know you solved it, but here is my solution, not even sure if this is what you wanted :D

    touch Controler

    but if your title is corect, in order to turn the angle towards a object position when you click it, just give it a target XY and use the sprites functionality "turn angle towards position" and it will rotate towards that object.

  • i know you solved it, but here is my solution, not even sure if this is what you wanted :D

    touch Controler

    but if your title is corect, in order to turn the angle towards a object position when you click it, just give it a target XY and use the sprites functionality "turn angle towards position" and it will rotate towards that object.

    Hello George! I tried your project.. It does work like i wanted... I'm studying your method, because I do not know this function.. Thanks!! always learning! ;)

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)