circle math help please
JScott
Member Posts: 143
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
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!
Thanks @Rainbros, trying now...
Age of Dominion RTS for iOS
Age of Dominion RTS for Android
Works great thanks!
Age of Dominion RTS for iOS
Age of Dominion RTS for Android