2 Replies Latest reply on Feb 6, 2007 6:42 AM by Nickname_is_none

    Restrict angle of camera rotation

      I've got a camera panning (using l/r/u/d) around a room from a single point of origin, using the lingo:

      if gPanRight then pCamera.rotate(1,0,0) --gPanRight refers to a mousedown on a seperate sprite

      I only want to allow the camera to move 180 degrees (90 in each direction)

      Any ideas on how to script this? I've this script (below) but do not know how to implement it:

      x = max(10,min(120, x - dragDist.locV))

      Is there an easier way?
        • 1. Re: Restrict angle of camera rotation
          duckets Level 1
          You might want something like this: Set up a property 'r'. Set it to zero on start. Then (each frame) modify that property when panning left or right, rather than rotating the camera directly, eg:

          r = r + (gPanRight-gPanLeft)

          Then limit 'r' to your chosen rotation limits:

          r = max(-90, min(90, r ))

          Then set your camera's rotational value directly:

          pCamera.transform.rotation.z = r

          (you may need to change which axis of your camera's rotation to change, depending on the orientation of your world).

          - Ben
          • 2. Re: Restrict angle of camera rotation
            Nickname_is_none Level 1
            Damnit!! I'm having trouble with this as well....

            These are the relevant parts I have at the moment:

            Movie script:
            on startmovie
            set pRestrict = 0

            3D world behaviour:
            property pRestrict

            on begineSprtie me
            pRestrict = pRestrict + (gPanRight-gPanLeft)
            pRestrict = max(-90, min(90, pRestrict))

            on controlCamera me
            if gPanLeft then pCamera.transform.rotation.y = pRestrict

            This has stopped the camera from panning at all! I have a feeling it might be glaringly obvious!!! Can anyone help (Mr Duckets?).