Working player + obstacle mvp

This commit is contained in:
Michal Pikulski
2025-11-20 12:24:56 +01:00
parent 28e6205bdd
commit af8cee1226
75 changed files with 7515 additions and 200 deletions

View File

@@ -17,6 +17,7 @@ namespace AppleHillsCamera
public enum AnchorEdge
{
Top,
Middle,
Bottom,
Left,
Right
@@ -49,6 +50,10 @@ namespace AppleHillsCamera
[Tooltip("Whether to account for this object's size in positioning")]
public bool accountForObjectSize = true;
[Header("Custom Anchor Point")]
[Tooltip("Optional: Use this child Transform's world position as the anchor point instead of calculated bounds")]
public Transform customAnchorPoint;
[Header("Visualization")]
[Tooltip("Whether to show the anchor visualization in the editor")]
public bool showVisualization = true;
@@ -302,10 +307,22 @@ namespace AppleHillsCamera
}
/// <summary>
/// Get the combined bounds of all renderers on this object and its children
/// Get the combined bounds of all renderers on this object and its children.
/// If customAnchorPoint is set, returns a zero-size bounds at the anchor point's world position.
/// </summary>
private Bounds GetObjectBounds()
{
// If custom anchor point is specified, use its world position as the bounds center
if (customAnchorPoint != null)
{
// Return zero-size bounds centered at the custom anchor point
// This makes the anchor point the exact position that will snap to the edge
Bounds customBounds = new Bounds(customAnchorPoint.position, Vector3.zero);
_objectBounds = customBounds;
return customBounds;
}
// Default behavior: calculate bounds from renderers
Bounds bounds = new Bounds(transform.position, Vector3.zero);
// Get all renderers in this object and its children
@@ -404,6 +421,8 @@ namespace AppleHillsCamera
{
case AnchorEdge.Top:
return referenceMarker.topMargin;
case AnchorEdge.Middle:
return 0f; // Middle has no margin
case AnchorEdge.Bottom:
return referenceMarker.bottomMargin;
case AnchorEdge.Left:
@@ -445,6 +464,10 @@ namespace AppleHillsCamera
// For top edge, offset is negative (moving down) by the top extent
offsetY = -extents.y - centerOffset.y;
break;
case AnchorEdge.Middle:
// For middle, no offset needed - object centers on middle
offsetY = -centerOffset.y;
break;
case AnchorEdge.Bottom:
// For bottom edge, offset is positive (moving up) by the bottom extent
offsetY = extents.y - centerOffset.y;
@@ -468,6 +491,11 @@ namespace AppleHillsCamera
newPosition.y = cameraPosition.y + cameraOrthoSize - margin + offsetY;
break;
case AnchorEdge.Middle:
// Position at the vertical center of the screen
newPosition.y = cameraPosition.y + offsetY;
break;
case AnchorEdge.Bottom:
// Position from the bottom of the screen
// When margin is 0, object's bottom edge is exactly at the bottom screen edge
@@ -518,6 +546,14 @@ namespace AppleHillsCamera
objectPosition.z
);
case AnchorEdge.Middle:
// Point at vertical center with same X coordinate as the object
return new Vector3(
objectPosition.x,
cameraPosition.y,
objectPosition.z
);
case AnchorEdge.Bottom:
// Point on bottom edge with same X coordinate as the object
return new Vector3(