PDA

View Full Version : Moving objects together


imperialkat
02-16-2010, 01:24 PM
How can I move one object based on where another object is moved?

I'm trying to simulate an object in front of a lens and the image it creates. There's one user-controlled object (A) on one side of the lens and another object (B) on the other side. When the user moves A relative to the lens I need B to 1)move a distance X (not necessarily the same distance) in the opposite direction and 2) change size based on its distance from the lens.

Jeff
02-16-2010, 05:35 PM
Use vizact.onupdate() or vizact.ontimer() to call a function every frame where you get the position of objectA. Based on that position or change from the previous frame you can set the new position of objectB and then scale it based on its distance from the lens.

imperialkat
02-17-2010, 12:43 PM
That helped out a lot. Thanks.