Rotation problem
tim13211
Member Posts: 87
I have square actors positioned in different parts of the scene. I need them to rotate, not from their center point but the center point of the screen. How can I accomplish this?
Example:
Example:
Comments
y=distance*(sin(angle))
is the formula that you need where x,y is the centre point of your blue squares and distance is the distance to your red center. So for every point around your black arrow circle you calculate a new xy based on a changing angle.
recently covered here :-
http://gamesalad.com/forums/topic.php?id=20867
and
http://gamesalad.com/forums/topic.php?id=19804
this diagram says it all
http://gamesalad.com/forums/topic.php?id=19860#post-151044
Tim, have you got yours working?
I'm confused on what the distance is supposed to be and the angle.
I probably didnt set it up right but what I have is-
I set up a game attribute, an angle, called game.rotation_angle
Red actor- contrain game.rotation to self.rotation
blue actor- constrain self.position.X to 25*(cos( game.rotation_angle ))
constrain self.position.Y to 25*(sin( game.rotation_angle ))
The problem is that the blue actor is rotating around X-0 and Y-0 of the screen (bottom left)
@Rob2 what am I doing wrong?
I've got the same thing now. What is the proper way to include the player's x and y?
How can I set the center point of rotation to the red actor. And also how can I maintain the blue actors current position before rotating, because right now all the blue squares I have on the scene are on top of each other.
I cant figure it out...
For them to maintain position before rotating, just have them only constrain using that formula when the event that causes them to rotate is true.
In other news, my attempts have failed and I've celebrated too early. It's more complicated because in mine, its a tank, which moves and rotates. I constrained the turret rotation to the tanks, and it worked. but as soon as I want to turn the turret, it all falls apart, unfortunately.
Since Gamesalad is a physics-centered program, wouldn't it make sense to include pivot points and that type of stuff?
for me i need the actors to rotate left (around the center or the scene) when the left key is pressed
my whole game depends on this so if it doesnt work i cant make the game
Could someone chime in before my head explodes again?
The red O is the center of the actor.
Ok, -23 is the distance between the middle of the turret and the middle of the turret ring, where the rotation point should be.
Note that in these, the rotation of the turret is the same as the rotation of the hull at all times. Like I said, when I want the turret to turn independently, it screws up big time.
http://www.coolmath-games.com/0-rotate-and-roll/index.html
As of now, there is no way I can finish my game. Which really is disappointing.