Spawn Actor

So in my game I'm making a game with an actor that spawns another actor wherever the player flicks/swipes the screen and an actor that moves right and controls camera. It works perfectly fine at first, but once the scene moves right, it only spawns them at the beginning of the scene.

How do I fix this?

Thanks in advance.

Comments

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    How are you setting up the spawn actor behavior? What are you using for the x position? Do you have it set to relative to the scene or to the actor? You may need an x offset depending on the position of the camera.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • hambuerger7hambuerger7 Member Posts: 45
    This is the code for spawning:

    When game.Up>50 (thats when they flick the screen)

    Spawn Actor: Paper in Front of Actor
    Direction: 0.0 relative to actor
    Position: game.releaseX (Mouse position X), 0 relative to scene.
  • hambuerger7hambuerger7 Member Posts: 45
    edited May 2013
    So I figured out that it wasn't working because it was spawning to the actual position in the scene.

    Ex:
    If the camera was showing the domain of [200,520] which would be literally on the iPhone [0,320] and I attempt to spawn it at (520,0), it will spawn at (320, 0) in relation to the scene.

    How do I fix this?
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    That what I meant by an offset. You need to factor in the difference between the camera position and the onscreen position. I believe it's the attribute called Current Scene.Camera.Origin.X, but I could be wrong. If you unlock an actor in the scene, you'll get access to that attribute (and others related to the camera). Just stick one or more of those attributes in a Display Text behavior and then watch what the values are when you play the game. That should help you figure out what to add/subtract to make it work.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • hambuerger7hambuerger7 Member Posts: 45
    For some reason the game.camera.origin.x is staying at 0 while it moves
Sign In or Register to comment.