1
\$\begingroup\$

Below I have an image describing the desired functionality I am going for. Let's say you control a square and when you move this square into a given area, any part of your rigidbody/model inside of the area will be magnified upon entering and shrunk upon leaving. So now you more or less are made up of two rectangles, one small and one large.

What would be an elegant approach towards achieving this effect?

enter image description here

\$\endgroup\$
  • \$\begingroup\$ Are you using Unity? \$\endgroup\$ – Selali Adobor Aug 16 '14 at 4:29
  • \$\begingroup\$ @TrevorPowell I have not implemented anything yet because I was afraid my approach would be overkill. I was initially going to have the object's transform be reinstantiated on every update based on where the intersection of the player and the area was. So initially we are made up of one rectangle and then right when we enter the rectangle, we destroy that initial rectangle and make our new object be comprised of a smaller rect representing the left side and a larger rect representing the part that has entered the "magnification zone". \$\endgroup\$ – Julian Aug 18 '14 at 14:38
  • \$\begingroup\$ @AssortedTrailmix Yes I am using Unity. \$\endgroup\$ – Julian Aug 18 '14 at 14:38
  • \$\begingroup\$ Then using multiple gameobjects with physics will be impractical Use the camera approach, possibly with an image effect to further the illusion of a "magnifying glass" \$\endgroup\$ – Selali Adobor Aug 18 '14 at 14:44
  • \$\begingroup\$ I like the idea. However, for my needs I think it may be too limited. The game is multiplayer and in some cases, one player walking into the zone will only cause him to grow in size while the other player walking into the zone will not do the same. Essentially, this transformation is not an illusion but actually happening in the world. \$\endgroup\$ – Julian Aug 18 '14 at 15:03
1
\$\begingroup\$

You can't do that with physics very easily (if at all).

A much simpler solution would be to use a second camera and calculate the viewport. The psuedocode would be something like:

if(magnificationCameraGO.IsVisible)
    magnificationCamera.enable;
    magnificationCamera.pixelRect.x = ConvertGameObjectPositionToCameraPosition(magnificationCameraGO.position.x)

You'd place the magnification camera on a gameobject, and position that gameobject where you want the magnification to appear

\$\endgroup\$
  • \$\begingroup\$ This would be my initial suggestion, try it out! \$\endgroup\$ – Tom 'Blue' Piddock Sep 17 '14 at 15:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.