Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: peaks on September 30, 2017, 11:53:16 AM

Title: controll light intensity with playerposition [SOLVED]
Post by: peaks on September 30, 2017, 11:53:16 AM
Hey everyone!

I need your help with this setup: I have a player (right now the stardard thridperson-controller from unity) and a point light. I would like to controll the light-intensity depending on the player position to that pointlight, something like this:

<(light int. 0)>-----------<(light int. 10 / max value)>-----------<(light int.0)>

I would like to have a border (something like a triggerbox) to start "tracking" the playerposition in "smooth" steps. If I'm really close to the pointlight, the value 10 should not exceed, if I'm moving away from that light the intensity gets lower again, till it reaches 0 / end of the triggervolume/ "border".

any help to achieve this setup?
Title: Re: controll light intensity with playerposition
Post by: djaydino on October 01, 2017, 12:41:04 AM
Hi,
Maybe something like this:
Create a sphere, set the radius on the desired size, set 'Is Trigger' and set it on the position where you want it to trigger (when the light need to start doing something)
Now you can remove the mesh or disable it. and you can set it as child on the light object if you want it to move together.

next, make an fsm

have a state with a trigger event and set on trigger enter, and you can store the object.
on the next state have a get distance(every frame enabled) and a on trigger exit.

Then you might need to multiple or divide that depending on your light intensity you want (for example your max intensity would be 20, and max distance 10, then you would need to multiply by 2)
after that you need use a float operator and then do 'max intensity' minus 'distance'

That result you can use to set the intensity.


(https://i.imgur.com/stL8Oab.gif)
Title: Re: controll light intensity with playerposition
Post by: peaks on October 01, 2017, 05:55:57 AM
peerfect! Thank you so much djaydino for your efforts!   ;D