Rotation around player. and Camera position,
Hello there. Im new to unity scripting, so far i try to figure out problems on my own but lately i cant seem to find a good solution for the problem im having.
when i move my character (BOX) from point A to B i made my box to rotate depending on the wall euler. this way the box is always 90 degrees to the wall. As you can see on the picture below.
so what im having problem is that when i make my camera follow the char. and it looks at him. it looks like on the left side of the image. And id like it to be like on the right side. is there a way to keep object towords another object angel fixed? like camera always looking at your right side even when you rotate or move.
hope any1 can find a solution tried many diffrent things and probobly got try more.
Answer by capu087 · Mar 16, 2016 at 10:58 PM
If you put the camera as a child of your player, isn't it following the player? and rotating when it rotates?
Answer by Szczesny · Mar 17, 2016 at 06:02 AM
Ok i fixed the problem it seems i didnt have to even use that much of a script after all. i just used transform.LookAt(player.transform.position);
where player= my character varible as a game object.
just seting my camera as a child will rotate it the same way i rotate parent the problem was it wasnt looking at parent as a center of hes orbit. solved it adding lookat to my camera script.
so i set my character as a parent to camera. didnt know it could work along so well. thanks capu :)