Problem with constrained actor

KrakenCMTKrakenCMT Member Posts: 22
edited November -1 in Working with GS (Mac)
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?

Comments

  • tenrdrmertenrdrmer Member, Sous Chef, Senior Sous-Chef Posts: 9,934
    Well it sounds like you are using one of TSB's templates to be honest. But either way. you need to place a control actor in the scene and unlock it so you can access the scene attributes. Then create game.offset.X and game.offset.Y real attributes and then constrain them to camera origin x and origin y using that unlocked controller actor.

    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
  • KrakenCMTKrakenCMT Member Posts: 22
    Thank you very much for the help! Unbelievably, I got it working now. I actually found exactly what you were talking about here:

    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.
Sign In or Register to comment.