Move and Rotate to position

JoshuaCaputoJoshuaCaputo Member Posts: 1
edited November -1 in Working with GS (Mac)
What I am trying to do is have the player move along a circular arc to the position that I tap.

I want it to rotate as well as move. So when it is at the end location it is facing the same way as the route is.

This diagram represents what I want. How would I do this?

[img]http://www.freeimagehosting.net/uploads/7093252547.png[/img]

Thanks,
Joshua Caputo

Comments

  • rebumprebump Member Posts: 1,058
    A bit of math to this one since all of GS' point-to-point movement is in a direct/straight-line manner.

    You would probably want to compute the mid-point between the actor position and the touch point. There is a math equation for that. Then compute another point that is offset to that mid-point (i.e. a certain number of pixels away). The imaginary line segment that would be comprised of the mid-point and the computed point would be perpendicular to the imaginary line between the actor position and the touch point. The computed point would then basically be the new mid-point of a circle's arc from the actor position, through the computed offset midpoint, to the touch point. The offset (i.e. length of the imaginary line segment) would need to be determined to provide an appropriate and/or pleasing arc size (i.e. its "arcy-ness"). Once you have that info, I think you would have enough to perform all sorts of circle/arc movement computations and could probably parlay it into the sin/cos circular movement demo found here:

    http://gamesalad.com/wiki/how_tos:gsc_circular_movement

    You may need to compute the center of the circle that the arc is a part of (and it would fall on a line that the imaginary line segment would be a part of). Then that could be the center point used in the sin/cos example.

    As with all things programming wise, there are probably a handful of ways to solve this issue and likely one of them may be even easier.

    I would like to tackle this one in a demo but I don't really have the time with all that is going on as I think it would take a bit of time.

    I'd like to provide more concrete math in my reply but haven't been in Trig for like 20 years. :-)
Sign In or Register to comment.