playMaker

Author Topic: How do I constrain camera position  (Read 1609 times)

Skaeren

  • Playmaker Newbie
  • *
  • Posts: 11
How do I constrain camera position
« on: December 09, 2015, 03:10:23 AM »
The app I am making is 2d, and I was wondering how do I constrain the position of the camera, so that user cannot move it beyond, for example, x 7:-7 and y 4:-4.

Skaeren

  • Playmaker Newbie
  • *
  • Posts: 11
Re: How do I constrain camera position
« Reply #1 on: December 14, 2015, 04:11:54 PM »
Kinda sd to see that there has been no response. Is it not possible to do this?

phannDOTde

  • Full Member
  • ***
  • Posts: 237
    • Peter Hann .de
Re: How do I constrain camera position
« Reply #2 on: December 14, 2015, 05:02:35 PM »
1. Get Cam position
2. clamp the position floats to the desired min max
3. set Cam position

do that in a loop or at every frame and you have your "hard" cam boundarys

Ps.: I guess there is no Vector clamp so you need to use Vector3 get XYZ and Vector3 Set XYZ and then clamp float on both of your axis