オブジェクトの座標を自然に制限する。
Public 変数
- Vector3 Horizontal
- Vector3 Vertical
Public 関数
- Vector3 LocalHorizontal (Vector3 pos, bool local)
- Vector3 LocalVertical (Vector3 pos, bool local)
- Vector3 TransformPosition (Vector3 localPos) // localPos => 0 ~ 1
- Vector3 InverseTransformPosition (Vector3 pos)
- Vector3 ClampPosition (Vector3 pos, bool lockLocalZ = true)
- void UpdateEdgePoint ()
Inspector 変数
- [GameObject]
- Camera cam
- Transform target
- [Plane Setting]
- Vector3 horizontal
- Vector3 vertical
- bool axisOrthogonal
- Vector3 center
- bool lock Center
- [Margin]
- rightMargin
- leftMargin
- upMargin
- downMargin
- [Option]
- bool clampOnUpdate
- bool updatePlane
- [Gizmos]
- bool drawCameraRange
- bool drawPlaneAxis
- float drawAxisSize
using From3DTo2D.ClampCamera;
public class Sample : MonoBehaviour {
public ClampCamera2D cc2d;
public float speed = 10f;
void Movement(Transform _transform, Vector2 stick) { //Call on Update()
Vector3 pos = _transform.position;
pos += speed * (cc2d.LocalHorizontal(pos) * stick.x + cc2d.LocalVertical(pos) * stick.y) * Time.deltaTime;
pos = cc2d.ClampPosition(position, false);
}
}

