Have Oner Actor Rotate Around Another?
JoshKahane
Member Posts: 470
Hi again. As I suddenly had an idea I have needed a flurry of help.
Sorry I know this is a well covered topic I just couldn't find the exact thing which I could manage to get to work.
Anyway we know it works, just who can spread the knowledge to my shriveled brain? It involves a small degree of maths so I can't handle it, hehe.
One catch, I will be starting with one actor rotating, but then I will have about 16 all at once. Will it cope? If not I would still like to know please! I have another plan. Thanks.
I would like one of my actors to rotate around my other actor in the center of the screen.
Sorry I know this is a well covered topic I just couldn't find the exact thing which I could manage to get to work.
Anyway we know it works, just who can spread the knowledge to my shriveled brain? It involves a small degree of maths so I can't handle it, hehe.
One catch, I will be starting with one actor rotating, but then I will have about 16 all at once. Will it cope? If not I would still like to know please! I have another plan. Thanks.
I would like one of my actors to rotate around my other actor in the center of the screen.
Comments
x = cos(angle) * radius
y = sin(angle) * radius
of course, this is a snapshot in time, to make them move you need a delta:
constrain attributes:
x = cos(angle * game.time * speedupvalue) * radius
y = sin(angle * game.time * speedupvalue) * radius
to make a circle that's more fluid and allows physics to operate on it you need to use centripetal acceleration:
a = v^2/r
where a = acceleration, v is the velocity, and r is the radius. If you need more help on that i suggest Khan Academy on youtube. Basically, you accelerate towards the center.
The physics based formula is nice if you want things to behave naturally on force of impact, but that means that the orbits can get knocked out of position and form weird eliptical orbits, etc. the trig functions are fixed functions that won't be bothered by physical impacts and will always have a perfectly circular orbit.
I think if you search 'floating shield' in shared projects it will come up
http://gamesalad.com/p/rebump/games
They all go about having one or more actors rotating about another. The lightsaber one also sits atop CodeMonkey's dual joystick demo.