movement box?

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
thanks
ryan
p.s. i want to be able to do this without using walls
Best Answer
-
tatiang Posts: 11,949
@pinata14 Please do! Thanks.New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Answers
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
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?
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
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
so have you tried it?
how did it turn out for you?
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User