Hi,
I have an issue with this script:
void Update ()
{
//if(!resetting)
//{
if (Input.GetMouseButton(0))
{
mouseHit = Camera.main.ScreenPointToRay(Input.mousePosition);
if (Physics.Raycast(mouseHit, out hit))
{
mousePos = Input.mousePosition;
currPoint = (hit.point - transform.position).normalized; //direction
if(mousePos != oldMousePos) // to make sure it will not keep moving when the mouse is stationary
{
axisToRotateAround = Vector3.Cross(prevPoint, currPoint); //axis to rotate around
angleToUse = Vector3.Dot(currPoint,prevPoint) ; // angle between the two vectors
//transform.rotation = Quaternion.AngleAxis(angleToUse , axisToRotateAround) * transform.rotation;
transform.RotateAround (axisToRotateAround,angleToUse * 8.0f * Time.deltaTime);
prevPoint = currPoint;
oldMousePos = mousePos;
}
}
}
If I make the rotation fast then I get a jitter/stutter when dragging http://www.artzfx.com/cnc/3dplayer02.html
If I slow it down then no jitter/stutter but the user has to do too much dragging around http://www.artzfx.com/cnc/3dplayer01.html
I changed from transform.rotation to transform.RotateAround() and added the multiplier of 8.0f which I have been playing around with. Also I have tried using FixedUpdate instead (plus lots of other code I have discarded).
Any help would be very welcome as I am looking for a smooth drag with no jitter.
The object in the example has a box collider and no rigidbody
thanks