Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by Kiloblargh · Mar 21, 2010 at 03:53 AM · rotationparentshadowprojectorblob

How to make a blob shadow project from a fixed angle as the object rotates?

If I have a blob shadow projector directly above my player object, and therefore the shadow directly below it, it works fine. But I want the sun to be not directly overhead but fixed at a slight angle. If the shadow projector is at an angle and parented to the player object, the blob shadow stays at that same relative angle and rotates around with the player object; not the effect I was looking for. I'm trying to make it follow the position but not the rotation.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
4
Best Answer

Answer by Eric5h5 · Mar 21, 2010 at 04:17 AM

Don't use parenting, but instead use a script that makes one object follow another object without rotating:

var objectToFollow : Transform; var offset : Vector3;

function Update () { transform.position = objectToFollow.position + offset; }

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Meltdown · Dec 27, 2010 at 09:07 AM 0
Share

Great stuff! Works for me although I didn't see the need for the offset variable :)

avatar image ActionScripter · May 24, 2012 at 04:08 PM 0
Share

I found this answer recently (because I had the same question), and I would like to offer an improved version that automatically orients the shadows to the sun's angle. Simply slap this code on a blob shadow projector, assign the variables in the inspector, and you're good to go!

(Note: this can be adapted to work with point lights. You would simply need to replace the Start code with a line in Update that gets the vector from the point light to the object.)


// ShadowFollow.js

#pragma strict

var objectToFollow : Transform; // The object you need a shadow under

var offset : Vector3; // How much to shift the projector from the object center

var lightSource : Light; // What light is "casting" the shadow

function Start () {

 transform.rotation = lightSource.transform.rotation;

}

function Update () {

 transform.position = objectToFollow.position + offset;

}

avatar image
0

Answer by Datael · May 25, 2012 at 06:14 PM

I have an alternative suggestion (and it will probably seem quite unusual) that uses parenting and will regrettably give you one extra game object, but it saves you from having to code at all.

If you create a new game object, call it, say, "Player Host" or something similar. Place the player object inside of this object at (0, 0, 0), then the object you want to follow it inside with it also. Now make your player move movement scripts target the host object, and the rotation scripts target the player object.

It's a bit convoluted but it will save you headaches in the long run. This theory can be applied in many situations, say if you wanted to make a planetarium.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

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

Answers Answers and Comments

1 Person is following this question.

avatar image

Related Questions

Blob shadow changes transparency 2 Answers

Do blob shadow projectors work on iPhone? 1 Answer

Projector (Blob Shadow) does not work properly 1 Answer

Blob shadow problem 2 Answers

[Unity3D 3.5.6f4] Get rid of shadow projector artefact 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges