Hello Guest

Author Topic: Colliders on screen / camera edge  (Read 3410 times)

mygamingproject

  • Newbie
  • *
  • Posts: 37
    • View Profile
Colliders on screen / camera edge
« on: August 27, 2014, 10:20:56 am »
I want to have it so that the screen edge is the limit of movement.  Coding this is straightforward but physics is involved so dont really want to be doing messy inverse forces to imply boundary checks.

What I was thinking was applying a "soft" material box collider to the left and right sides of the camera view but then thought about the issue of different screen resolutions widths i.e. iphone5 over iphone4 for example. 

Is it possible to anchor a box collider on either side but out of view to achieve this effect.  If so how is best to accomplish it?

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Colliders on screen / camera edge
« Reply #1 on: August 27, 2014, 10:42:46 am »
You can try using a tk2dCameraAnchor to anchor these objects to the edges of the screens.

mygamingproject

  • Newbie
  • *
  • Posts: 37
    • View Profile
Re: Colliders on screen / camera edge
« Reply #2 on: August 27, 2014, 11:00:06 am »
I thought of those but assumed that might only work within the camera bounds not outside of it

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Colliders on screen / camera edge
« Reply #3 on: August 27, 2014, 11:25:59 am »
They just position the object at the bounds. Its up to you to then make the attached collider extend outwards rather than in.