-1

I have objects that I want to rotate towards a collision point, but only on the Y-axis. Here's what I mean:

  1. The arrows show which direction the balls hit the pins. First
  2. The object rotates on it's Y-axis to face the collision point. Second

I suspect what I need is to convert the Vector3 of the collision point into rotational degrees, that can then be plugged into the object's Y axis. I have no idea how to do this, or if it's even possible. Can anyone help me?

1 Answers1

0

Why don't you simply use Unity's LookAt function like this:

transform.LookAt(new Vector3(Target.position.x, transform.position.y, Target.position.z));
  • `Light.transform.LookAt(new Vector3(0, point.y, 0));` I tried this. Didn't work. [Result](https://imgur.com/9YVVHXF) – ShatteredSanity Oct 28 '20 at 23:30
  • The thing is if you need to rotate about y axis, you should get the x and z coordinates of your point, not the y – Anis Brachemi Oct 28 '20 at 23:34
  • Maybe I said it wrong then? I'm trying to change the rotation of the Y. I guess that's not exactly the Y axis? Which Axis would it be? Sorry, I'm not very good at this :T – ShatteredSanity Oct 28 '20 at 23:55
  • Yes exactly, if you want to change the rotation of Y, you must look at the x and z coordinates of your target – Anis Brachemi Oct 29 '20 at 00:56