Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- public class CloudShadow : MonoBehaviour
- {
- #region Fields
- private GameObject sun;
- private Projector cloudShadow;
- private RaycastHit hit;
- #endregion
- void Start ()
- {
- // Find your sunlight by it's name
- sun = GameObject.Find("Sunlight");
- cloudShadow = GetComponentInParent<Projector>();
- }
- void Update ()
- {
- // Cast a Raycast from the cloud to the sun's direction
- if(Physics.Raycast (transform.parent.position, sun.transform.forward, out hit))
- {
- // Height is fixed at 1000 as it fits my game - apply what you need
- transform.position = new Vector3(hit.point.x, 1000f, hit.point.z);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement