Skip to content

kuritaro1122/ClampCamera2D

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ClampCamera2D

オブジェクトの座標を自然に制限する。

【HyperNovaで使用している様子】

photo

【簡易リファレンス】

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

inspector

Example

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);
  }
}

About

[Beta]オブジェクトの座標を自然に制限する。

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages