Angle lock

0 favourites
  • 4 posts
From the Asset Store
3D Car Pack 1
$2.99 USD
3D models + Rendered Low-Poly Cars in isometric, top-down, and side angles.
  • Trying to do a drag and drop type action, something like you would have for inverse kinematics, where another object's angle determines how far, and what angles it can bae dragged to.

    I have something using conditionals using angledif<45 ? object.x+cos(angle(object.x,object.y,touch.x,touch.y)*clamp(distance(object.x,object.y,touch.x,touch.y),0,max) :self.x

    However I'm wondering if there was a better approach.

    I tried clamping the cos(angle()) to the object.angle-45 min, and object.angle+45 max, but that doesn't workout because of the -180 from angle().

  • If you have the center angle you can do something like

    set angle to centerAngle+calmp(angle(0,0,cos(angle-centerAngle),sin(angle-centerAngle)), -45,45)

  • Thanks I'll play around with that.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I finally came across this formula:

    object.X+cos(angle(object.X,object.Y,touch.X,touch.Y))*clamp(distance(object.X,object.Y,touch.X,touch.Y)*cos(Angle(object.X,object.Y,touch.X,touch.Y)),0,256)

    Not sure why, but I had to use cos(Angle(object.X,object.Y,touch.X,touch.Y)) on the y part. It would not work with sin.

    Edit: nevermind

    Same deal with angle()

    Edit 2:

    Fixed it with anglediff... sort of.

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