Im trying to move a circular gameobject along a surface and then rotate it around the corner / end point of that surface.
I think it can be soloved using trigonometry, but not 100 percent sure.
I can move the object along the surface using this calculation…offset = tan(A) x radius of circle. this gives me a distance I can offset the circle by, but having trouble with the rotation.
please see attached image for a better understanding of what i am trying to achieve.
[3226-offset+problem-unity-page-001.jpg|3226]
It would be really helful if anyone can give me any advice on how to to resolve this problem.
thanks in advance.
javascript code for stage1 of the diagram…
var player : GameObject;
var d1 : float = 1;
var offset : float = 0;
function Update () {
var angleA : float = Vector3.Angle(player.transform.position - transform.position, transform.forward);
var angleB : float = 90 - angleA;
var angleC : float = angleA + angleB;
var angleCRadians : float = angleC * (Mathf.PI/180);
var angleCTan = Mathf.Tan(angleCRadians);
offset = angleCTan x d1;
transform.position += transform.TransformDirection(Vector3( -offset, 0, -d1));
}