How can I drag an actor along a specific angle?

twinpixtwinpix Member Posts: 49
edited August 2014 in Working with GS (Mac)

Does anyone know the expression required to make an actor constrain to a certain angle when dragged?

I have an actor BALL with a boolean "draging" attribute. When touched, the "dragging" is set to true. When "dragging" is true, BALL position X and Y are constrained to Touch X, Touch Y. The user can drag BALL anywhere.

What I want, however, is for BALL to be constrained to an angle, say 45 degrees, relative to the screen when "dragging" is true. So it is constantly snapping it's position to 45 degrees (relative to the scene).

So, in the image below, I want to be able to drag the ball between points A and B, but have it constrain to the black line.

Comments

  • jigglybeanjigglybean Member Posts: 1,584

    this may help a bit

    Like Balls? Then click here! We've 100 coming soon

  • twinpixtwinpix Member Posts: 49

    Thanks but I'm not sure how that would help. The ball actor isn't actually moving, so there's no linear velocity set to it. I'm just trying to constrain the ball's draggable position to 45 degrees. So when a person drags the ball it will only move along the black line between points A and B above.

    Can you help me figure out how the VectorToAngle expression works when there's no linear velocity of the actor?

  • ArmellineArmelline Member, PRO Posts: 5,374

    Perhaps something like this? Drag to move the two start points (the white actors). When I made this it wasn't essential that the moving actor be constrained exactly to the touch position, so it moves based on the position and direction of the touch/drag instead.

    Perhaps it'll be of help though. It met my needs at the time so I'm sure it can be greatly improved to suit your specific purpose.

Sign In or Register to comment.