Problem with constrained actor
I've been learning a lot these last few days about GameSalad, and have started a game of my own. But I've run into a problem.
My game space is 960 px tall x 320 px wide. I have an arrow actor that is constrained to the x & y position of the mouse when pressed and it points in the direction that the player will move. It works perfectly until the camera starts scrolling up. When the camera scrolls up, the arrow that is supposed to be constrained to my mouse position, but is now lower than where the mouse is clicking the screen. Therefore the player actor moves in the wrong direction. It's like the mouse click is relative to the original position of the camera and not to the position relative to the camera's new position.
This is how I have the arrow actor set up:
Attribute game.ClickOnPlayer is true
Constrain self.position.X to game.Mouse.Position.X
Constrain self.position.Y to game.Mouse.Position.Y
Attribute game.ClickOnPlayer is false
Constrain self.position.X to self.InitX
Constrain self.position.Y to self.InitY
There's other rules in there that pertain to constraining the rotation angle and how fast the player moves, but I don't think they are relevant.
Any ideas on why this is happening?
My game space is 960 px tall x 320 px wide. I have an arrow actor that is constrained to the x & y position of the mouse when pressed and it points in the direction that the player will move. It works perfectly until the camera starts scrolling up. When the camera scrolls up, the arrow that is supposed to be constrained to my mouse position, but is now lower than where the mouse is clicking the screen. Therefore the player actor moves in the wrong direction. It's like the mouse click is relative to the original position of the camera and not to the position relative to the camera's new position.
This is how I have the arrow actor set up:
Attribute game.ClickOnPlayer is true
Constrain self.position.X to game.Mouse.Position.X
Constrain self.position.Y to game.Mouse.Position.Y
Attribute game.ClickOnPlayer is false
Constrain self.position.X to self.InitX
Constrain self.position.Y to self.InitY
There's other rules in there that pertain to constraining the rotation angle and how fast the player moves, but I don't think they are relevant.
Any ideas on why this is happening?
Comments
Then you will then need to add or subtract those offsets attributes from anywhere the mousepositions are references. And if I right and its TSB's deal then you will have a lot of place to do that to make it all work. I just did this for someones project that was based off of one of the control templates. you will have a lot of trial and error to get it right. but it is doable.
___________________________________________________________________________________
TEMPLATES AND PROJECT HELP BY TENRDRMER. CLICK HERE!!!
AppSolute Entertainment on Facebook
AppSolute Entertainment on iTunes
http://gamesalad.com/wiki/how_tos:gsc_drag_and_drop_movement#modifications_for_non-default_scene_size
Yeah, I've been borrowing many rules and code from the GameSalad project library and the forums here plus going through lots of trial and error trying to make it all work. Been a little rough at times, but it's coming together nicely. Things are starting to click a little more.