Hi, I have a question relating blob shadows that I've come across.
Just starting, I am able to attach blob shadows to objects, and get a blob shadow to move with it. I have also looked at another question's script, which forces the blob shadow to always face downward even though its parented to another object. I have also been able to ignore layers, so the shadow will not be displayed on the object itself.
The blob shadow gets bigger when the object moves away from a surface. What I want is the blob shadow to get smaller as it moves away. This'll make the blob shadow appear from nowhere, rather than a large black dot appearing, before it shrinks and the object lands.
I hope you guys can help! :D
You need code that makes the projector move downwards when the object moves upwards.
Paste this code to a new C# script. Assign it to your object, then drag and drop the blob shadow projector to the script's shadow property.
EDIT: Doing the changes required by Biendeo was harder than I thought, but eventually I figured out a solution.
using UnityEngine;
using System.Collections;
public class InverseYMovement : MonoBehaviour
{
public Transform shadow;
public float characterHeight = 5.0f;
private float initialY = 0.0f;
private float groundHeight = 0.0f;
void Start()
{
initialY = shadow.transform.position.y;
}
void LateUpdate()
{
Vector3 pos = shadow.transform.position;
pos.y = groundHeight + initialY - (transform.position.y - groundHeight);
shadow.transform.position = pos;
RaycastHit hit;
int groundLayers = 1 << 0; // put here the layer where the ground/platforms are
if (Physics.Raycast(transform.position + new Vector3(0, characterHeight, 0), -Vector3.up, out hit, Mathf.Infinity, groundLayers))
{
groundHeight = hit.point.y;
}
}
}
HAVE YOU TRIED FLIPPING THE PROJECTOR UPSIDE DOWN LOL