Ok I don't know how the hell that other script is supposed to function, but here's mine.
The "5f" value affects how high above the ball the shadow projector is, you can change it to whatever you like, it affects how much the size of the shadow changes with distance from floor. Actually the commented out code is the original "transform.position = transform.parent.position + Vector3.up * 15f;"
Make sure the projector is a child of the ball.
//BlobShadowController.cs
using UnityEngine;
using System.Collections;
public class BlobShadowController : MonoBehaviour
{
void Update()
{
transform.position = transform.parent.position + Vector3.up * transform.parent.localScale.y * 5f;//* .50f;
// transform.position = transform.parent.position + Vector3.up * 15f;
// Debug.Log(transform.position);
transform.rotation = Quaternion.LookRotation(-Vector3.up, transform.parent.forward);
}
}
↧