Camera Rotation Problem - Help needed
Stoneclipse
Member, PRO Posts: 130
Hi I am making my game to have the camera follow my actor rotation. I followed this video and managed to have the HUD stays in place when rotating.
However the problem is how can i add a score actor and have it stay in place when rotating the camera? Help pls. I have been working on this the whole afternoon and still can't get it to work. I know you have to use sin and cos but i have no idea about the exact equation.
However the problem is how can i add a score actor and have it stay in place when rotating the camera? Help pls. I have been working on this the whole afternoon and still can't get it to work. I know you have to use sin and cos but i have no idea about the exact equation.
Comments
So lets say you want the score actor to be in the upper left portion of the scene. The angle for upper left would be something in the range of 135 degrees. The distance from the center of the scene might be 200 pixels. The behaviors would look something like this in an unlocked actor:
Constrain Attribute:[self.rotation] To:[- scene.Camera.Rotation]
Constrain Attribute:[self.Position.X] To:[200*(cos(- scene.Camera.Rotation +135))+( scene.Camera.Origin.X +( game.Screen.Size.Width /2))]
Constrain Attribute:[self.Position.Y] To:[200*(sin(- scene.Camera.Rotation +135))+( scene.Camera.Origin.Y +( game.Screen.Size.Height /2))
Once you get it working, the only changes you will need to make are messing with the angle (135) and the distance (200) until you get the actor placed where you want. All the rest never changes.