x


Blob Shadow Always Pointing Down?

I have a ball (rigidbody, can move rotate etc) that I want a simple blob shadow on, so I attached a projector. The problem is, the projector rotates with the ball when it is moving around... Is there a simple way to keep the shadow projector pointed "down" (which is actually at a wall in my game).

Thanks!

more ▼

asked Jun 29 '10 at 05:35 AM

Andrew 4 gravatar image

Andrew 4
61 1 1 6

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

Yep, there's a script that was developed specifically for that (speaking of which, I need to implement soon into my game). Oh, the script is written in CS (C sharp format). Just attach this script to the object with the blob shadow.

using UnityEngine;
using System.Collections;

public class BlobShadowController : MonoBehaviour
{
    void Update()
    {
        transform.position = transform.parent.position + Vector3.up * 8.246965f;
        transform.rotation = Quaternion.LookRotation(-Vector3.up, transform.parent.forward);
    }
}
more ▼

answered Jun 29 '10 at 06:01 AM

CarbonTech Software gravatar image

CarbonTech Software
256 17 17 30

Thanks for the help! I can't seem to get it to work though... I have a ball prefab with a projector component set to a blob shadow material (and it also ignores the layer "NoShadow", which the ball is on), but I don't see a shadow. When I look at it running, it also looks like the projector is still rotating. All of this happens when I attach the script to the ball prefab. Am I doing it right? I am new to Unity :p

Jun 29 '10 at 10:29 PM Andrew 5

Never mind! I got it figured out (created a separate shadow object, added the ball and shadow projector object into one prefab, assigned a script to the projector part of the prefab)

Jun 29 '10 at 10:39 PM Andrew 5

Thanks! This is exactly what I was looking for

May 25 '12 at 01:25 AM formidable
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x217
x109
x28

asked: Jun 29 '10 at 05:35 AM

Seen: 2112 times

Last Updated: May 25 '12 at 01:25 AM