- Home /
Question by
rav90 · Oct 15, 2010 at 07:49 AM ·
moveballonmousedown
moving a ball when touch
function OnMouseDown()
{
//for(i=1; i<=touch; ++i)
while(Vector3.Distance(transform.position,nextPos[i+1]) >1)
{
if(transform.position.x - nextPos[i+1].x >0 )
{
transform.position.x-= Time.deltaTime * 0.1;
}
else
{
transform.position.x+= Time.deltaTime * 0.1;
}
if(transform.position.z - nextPos[i+1].z >0 )
{
transform.position.z-= Time.deltaTime * 0.1;
}
else
{
transform.position.z+= Time.deltaTime * 0.1;
}
}
i++;
}
plz can any one say is this correct code to move object like a ball into certian position when click on that object???
Comment
Please format your code (click the button with 0s and 1s) and try to add useful/relevant tags (i.e. not "tags")
And rather update your original than to ask another: http://answers.unity3d.com/questions/23597/moving-a-ball-when-touch