control camera with a GameObject

Hi,

i have a gameobject relative with a camera ( GO is child of Camera), in my case i want camera work follow step

  1. step 1: camera rotate around object by touch ( close distance with object, object in front of camera)

  2. step 2: push object with addForce and camera look object ( no need to follow object)

  3. step 3: when velocity of gameObject = 0.5 i want camera return original setting ( follow object and can rotate around object with close distance)

im done step 1,2 but still need help step 3

please help!

2 Answers

2

If the gameobject has a RididBody on it you can check its velocity easily. Otherwise you have to compute velocity yourself. Keep track of ‘last position’ in an Update function, subtract last position from current and divide by Time.deltaTime to get velocity.

Thanks Dave!
but my problem ísn’t get Velocity
My problem is how to attach GameObject(has rigidBody) with a Camera
case 3: gameObject push by addforce and run, after it stop, i want attach camera to it like begin state ( in my case GameObject is child of Camera)