movement box?

pinata14pinata14 Member Posts: 150
edited April 2012 in Working with GS (Mac)
hi, is there a function that can constrain an actor's position to between X1 and X2 and Y1 and Y2? i want to have an actor that like the camera, only moves within a certain tracking area around the player, except for this actor will be the one controlling the camera (so that the camera will always be in front of the player instead of centered around it.
thanks
ryan
p.s. i want to be able to do this without using walls

Best Answer

Answers

  • pinata14pinata14 Member Posts: 150
    bump
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

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

  • pinata14pinata14 Member Posts: 150
    @tatiang
    thanks, but i just realized i want it to be the opposite... is there a way to have it so that the camera's tracking area position changes? because i want to have the camera always be in front of the player so that you can see in front of you. so if you move up the camera tracks a position say 100 above the player etc. i found a way to do this, but i want to make it smooth so any ideas?
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    Well, it sounds like you've already found the scene.camera attributes. As far as smoothing it out, that's something I'm working on with my own game right now. I haven't had a lot of success, but one thing @tshirtbooth suggests is unlocking actors that you intend to follow via constrain behaviors and instead of constraining the following actor AND the follower actor, only do one:



    Another thing I've read is to place the camera actor (if you have one) in a layer below your main character or other actors. Also, if possible, have the player actor be the camera itself (Control Camera behavior) rather than having a separate actor to do this.

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

  • pinata14pinata14 Member Posts: 150
    ok i found a way to do it... its 95% smooth. let me know if you want to know and ill tell you when i get the free time
  • pinata14pinata14 Member Posts: 150
    @tatiang
    ok, sorry for the 9 hour delay :P
    anyway you basically want to have a different actor control the camera. this actor is set to rule
    when-any of the movement keys are down
    then-move in direction (vectorToAngle(scene.background.player.motion.linear.velocityX (we'll call this "LVX")-player positionX, LVY-player positionY)) *This makes it move in the direction the player is travelling* at speed (some speed faster than player movement)
    otherwise-interpolate (self x/y to player x/y) at speed (whatever but .5 works good for me)
    ---
    also if you have a big map, you might have to make walls that follow the players coords + (xxx) so that there is an effective "tracking area" that the control actor cant escape from. otherwise the control actor since its going faster than the player will keep going and the player willl go off the screen.
    Hope this helps you! let me know if you run into any problems
  • pinata14pinata14 Member Posts: 150
    @tatiang
    so have you tried it?
    how did it turn out for you?
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    @pinata Sorry, I haven't yet but I have this page bookmarked and will comment again once I have.

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

Sign In or Register to comment.