Skip to content
This repository has been archived by the owner on Apr 27, 2024. It is now read-only.

Commit

Permalink
Minor fix for scaling shadows of placeable objects
Browse files Browse the repository at this point in the history
This change fixes the scaling of shadows for placeable objects on a
horizontal surface. Thanks goes to lukaswerz (from our forums) for
pointing out the bug and solution.
  • Loading branch information
angelaHillier committed Jan 5, 2017
1 parent 81ab807 commit 13f19be
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions Completed/Planetarium/Assets/Scripts/Placeable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -507,15 +507,20 @@ private void DisplayShadow(Vector3 position,
Vector3 surfaceNormal,
bool canBePlaced)
{
// Rotate the shadow so that it is displayed on the correct surface and matches the object.
// Rotate and scale the shadow so that it is displayed on the correct surface and matches the object.
float rotationX = 0.0f;

if (PlacementSurface == PlacementSurfaces.Horizontal)
{
rotationX = 90.0f;
shadowAsset.transform.localScale = new Vector3(boxCollider.size.x, boxCollider.size.z, 1);
}
else
{
shadowAsset.transform.localScale = boxCollider.size;
}
Quaternion rotation = Quaternion.Euler(rotationX, gameObject.transform.rotation.eulerAngles.y, 0);

shadowAsset.transform.localScale = boxCollider.size;
Quaternion rotation = Quaternion.Euler(rotationX, gameObject.transform.rotation.eulerAngles.y, 0);
shadowAsset.transform.rotation = rotation;

// Apply the appropriate material.
Expand Down
Binary file modified Starting/Planetarium.unitypackage
Binary file not shown.

0 comments on commit 13f19be

Please sign in to comment.