playMaker

Author Topic: controll light intensity with playerposition [SOLVED]  (Read 1369 times)

peaks

  • Playmaker Newbie
  • *
  • Posts: 27
controll light intensity with playerposition [SOLVED]
« 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?
« Last Edit: October 01, 2017, 09:11:25 PM by djaydino »

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7615
    • jinxtergames
Re: controll light intensity with playerposition
« Reply #1 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.



peaks

  • Playmaker Newbie
  • *
  • Posts: 27
Re: controll light intensity with playerposition
« Reply #2 on: October 01, 2017, 05:55:57 AM »
peerfect! Thank you so much djaydino for your efforts!   ;D