Hello
I am currently working on a multiplayer game where the player is instantiated over the network in the scene. The players camera has the SunShafts C# script attached. However with this game it does include a day & night cycle, so my question is. Is there anyway to update the sun shafts position and rotation and center it on the player camera as the games day progresses? For example when the game starts to transition to sunset the sun shafts will still be showing in the morning position, it just causes an unrealistic effect.
Any help would be greatly appreciated, thank you!
The SunShafts position should update if you set the shafts caster to a moving transform. I do this for a visual effect which appears in various positions in my project and it works well.
In theory, if you make the shafts caster a child of your sun transform and offset it on the Z axis to a great distance, you should be able to get the sun rays to follow the sun across the sky.
What I used to do was attach a script to the camera which creates an empty gameobject and, in update, sets the position like
ppTransform.position = cameraTransform.position - SunTransform.forward * (someBigNumber);
Then assign the sunshaft image effect’s target to the new gameobject’s transform.