Unity/Unity Study
unity - camera smooth follow
붕대마음
2013. 11. 16. 14:18
반응형
if(cameraFollowX)
{
Vector3 targetPos = new Vector3(cameraTarget.transform.position.x, thisTransform.position.y, thisTransform.position.z);
Vector3 localVel = new Vector3(velocity.x, 0.0f, 0.0f);
thisTransform.position = Vector3.SmoothDamp(thisTransform.position, targetPos, ref localVel, smoothTime);
}
if(cameraFollowY)
{
Vector3 targetPos = new Vector3(thisTransform.position.x, cameraTarget.transform.position.y, thisTransform.position.z);
Vector3 localVel = new Vector3(0.0f, velocity.y, 0.0f);
thisTransform.position = Vector3.SmoothDamp(thisTransform.position, targetPos, ref localVel, smoothTime);
}