- Home /
Moving a cylinder connecting two spheres
I have a question on this topic and the answer above does not seem to address it. My problem is this:
I have two spheres where are moving along a path using iTween (they represent two points along a cylinder - the middle and the top). The paths that the spheres travel on was determined through motion capture data of a person swinging a bat like object. I am trying to have a cylinder object follow a path that essentially goes through both these points. The two spheres are essentially markers on the cylinder object.
Right now I have a line renderer object that is drawing a line between both spheres. I want to replace the line renderer with a solid cylinder. For example, if the bottom marker is at (0,0,0) and the top marker is at (0,1,0) I would like my cylinder object to be perfectly upright along the y-axis. Similarly, if the bottom marker is at (0,0,0) and the top marker is at (0,0,1) I'd like the cylinder object to lie horizontal along the z-axis.
My approach is to have the cylinder follow one of the marker's path and find the angle made between both markers to have the cylinder object orient itself at that angle. This is proving to be quite difficult and I could use some help. Has anyone come across a similar problem?
Any help would be greatly appreciated. I've tried just about everything I could find to accomplish my goal but it just simply isn't working.
I would also like to do this via a script component because the two markers (and their paths) will be changing based on motion capture data.
Thanks for your help in advance.