circle math help please

Hi, I'm trying to figure out how to get actors to move to random points around an imaginary circle's diameter, from a starting point. I want actors to move to another actor, but instead of moving to the centre point, moving to a random point around it, a set distance from it, but random points.

Make sense?

I've got a hacked out sort of solution, but I know there is some sort of cosinepianti-matter equation that you smart people know that will fix all of my problems!

Any help appreciated!

Comments

  • RainbrosRainbros Member Posts: 124
    edited September 2015

    In the actors you want moved, make a new angle attribute called angle and a real or integer attribute called distance.

    Change angle to: random(1,360)
    Change distance to: random(minimum distance,maximum distance) (only if you want random distances from the circle)
    Change x position to: circleCenterX + circleRadius + cos(angle) * distance
    Change y position to: circleCenterY + circleRadius + sin(angle) * distance

    The circleCenter numbers are just the coordinates of your imaginary circle, and circleRadius is half the diameter.

    That's it!

  • JScottJScott Member Posts: 143

    Thanks @Rainbros, trying now...

  • JScottJScott Member Posts: 143

    Works great thanks!

Sign In or Register to comment.