37 lines
941 B
C#
37 lines
941 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class castShadow : MonoBehaviour
|
|
{
|
|
public bool refreshEverySecond = true;
|
|
public Environment environment;
|
|
public sbyte shadowStrength = 50;
|
|
Vector3 oldPosition;
|
|
void Start()
|
|
{
|
|
oldPosition = transform.position;
|
|
environment.addShadow(transform.position, shadowStrength);
|
|
}
|
|
int frame = 0;
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
if(frame == 2)
|
|
{
|
|
}
|
|
if(refreshEverySecond&&frame%60==0&&frame>60)
|
|
{
|
|
if(oldPosition != gameObject.GetComponent<Transform>().position)
|
|
{
|
|
environment.removeShadow(oldPosition, shadowStrength);
|
|
environment.addShadow(transform.position, shadowStrength);
|
|
oldPosition = transform.position;
|
|
}
|
|
|
|
}
|
|
frame++;
|
|
}
|
|
}
|