Can camera control not affect mouse position and spawning?

TouchTiltGamesTouchTiltGames Member Posts: 1,162
edited November -1 in Working with GS (Mac)
Hoping someone can help with a small thing, but a big thing for me. I've got an invisible container constrained to my mouse position and when you click it spawns a block that falls down on the release, only my game scrolls up vertically and as soon as the camera starts to track/follow the actor that's jumping up, I lose the ability to spawn anymore blocks. I figured this tutorial would help:

http://gamesalad.com/wiki/how_tos:gsc_drag_and_drop_movement#modifications_for_non-default_scene_size

but I'm not sure if it's the right tutorial for what I want to do. I did try this but I think I had the behaviours in the wrong place given that my setup is different?

Is there a way of not having the mouse position/block spawning be affected by the camera movement/tracking?

Hope someone can lend a hand here, thanks!

Comments

  • firemaplegamesfiremaplegames Member Posts: 3,211
    You need to account for the camera offset and add it to your coordinates.

    Here is how you do that:

    Create two global game attributes called CameraX and CameraY.

    Create a new Actor called CameraTracker. A simple box will do. Do NOT put any code in the Prototype.

    Drag the CameraTracker Actor into the Scene, and place it just outside of view.

    Double-click on the CameraTracker Actor in the Scene and open the padlock.

    Add two Constrain Attribute behaviors to the CameraTracker instance:

    Constrain Attribute: game.CameraX To: Scene.Camera.Origin.X
    Constrain Attribute: game.CameraY To: Scene.Camera.Origin.Y

    So:

    When you spawn something, use:

    [spawn.X] + game.CameraX
    [spawn.Y] + game.CameraY

    Hope this helps!

    Joe
  • TouchTiltGamesTouchTiltGames Member Posts: 1,162
    Thanks, Joe! So when I'm spawning the blocks do I setup a change attribute on the blocks for the:

    [spawn.X] + game.CameraX
    [spawn.Y] + game.CameraY

    ?

    And I assume "spawn" is another attribute I'd need to create?

    Cheers,
    Shane
  • firemaplegamesfiremaplegames Member Posts: 3,211
    Hey,

    So all I meant was that you have to add the camera offset to your spawn position.
    In your case above, the spawn position would be the Mouse Position.

    So, instead of just spawning a new Actor at your Mouse Position, you need to spawn the Actor at the Mouse Position PLUS the distance that the camera has moved. Use the steps above to capture the current camera coordinates.

    This is only an issue if your Scene is larger than the screen, and has to scroll.

    Does that make sense?

    EDIT: And I do not in any way mean for this to sound harsh, but if anything that I have said is confusing, like spawning, or attributes - then I strongly recommend that you get a better grasp of the basics of GameSalad before tackling something like this. This is fairly complex stuff, and if your foundation is a bit rocky, it's going to start to get away from you.
  • TouchTiltGamesTouchTiltGames Member Posts: 1,162
    Hey,

    Really appreciate this. Yeah I'm close but just can't do your last step for some reason, as soon as the Actor jumps up past the tracking area and the screen starts to scroll, I lose control of spawning blocks and they don't spawn anymore.

    No problem, I do understand Spawning and Attributes...just not sure where to add the game.CameraX with the spawning..tried numerous things.

    Well here's a screenshot of my rules on the invisible container in my Scene that spawns random blocks: http://www.shanewhitehouse.com/cameraoffset.png

    I have the dummy camera tracking block setup properly off the screen.

    Adding game.CameraX to the Constrain attribute there doesn't work or adding it to an Attribute right on the spawn block rule itself doesn't work either :(
  • TouchTiltGamesTouchTiltGames Member Posts: 1,162
    Can anyone help with my last problem? :) I'm so close to getting this important play mechanic working in this game I'm creating.
  • arsenio808arsenio808 Member Posts: 4
    Hi Joe. Arsenio here and new to GameSalad.. did your method require the brackets? [spawn.X]+game.CameraX?
  • arsenio808arsenio808 Member Posts: 4
    Hi Joe, one more question? Doe's that apply to VectorToAngle(x-x,y-y)?
  • arsenio808arsenio808 Member Posts: 4
    Got it thanks!
  • arsenio808arsenio808 Member Posts: 4
Sign In or Register to comment.