2D Toolkit Forum

2D Toolkit => Support => Topic started by: mygamingproject on August 27, 2014, 10:20:56 am

Title: Colliders on screen / camera edge
Post by: mygamingproject 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?
Title: Re: Colliders on screen / camera edge
Post by: unikronsoftware on August 27, 2014, 10:42:46 am
You can try using a tk2dCameraAnchor to anchor these objects to the edges of the screens.
Title: Re: Colliders on screen / camera edge
Post by: mygamingproject 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
Title: Re: Colliders on screen / camera edge
Post by: unikronsoftware 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.