c# - Unity transform.LookAt() not updating with a moving target -


my camera casts ray centre of screen , have object looks @ direction. problem is, made such keys rotate camera, there's new centre, , ray camera moves object doesn't @ new direction

here's code:

 void update (){  int x = screen.width / 2;  int y = screen.height / 2;   //get centre of screen camera  ray ray = camera.main.screenpointtoray (new vector3 (x, y));  debug.drawray (ray.origin, ray.direction * 1000, new color (1f, 0.922f, 0.016f, 1f));   //set object direction  object.transform.lookat (ray.direction);  } 

i'd appreciate this, thank you!

i found solution. instead of looking @ ray direction, got point ray using getpoint , made object @ that. it's working fine now.


Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -