Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: Arnoob on March 05, 2017, 11:35:56 AM

Title: Getting light component from a game object[SOLVED]
Post by: Arnoob on March 05, 2017, 11:35:56 AM
Hello every one.

In order to make some assets work correctly, I need to show to a script what directional light it needs to use. Using the "set property" node, I can set the light component. However, I don't know how to GET the "light" component from a game object.

Also, I tried the "get component" nodes, but I can't understand how it works, are they bugged?

So TLDR: how can I get a light component in playmaker?

I'm sure the answer is silly easy, but I can't find it so far :-/
Title: Re: Getting light component from a game object
Post by: mdotstrange on March 05, 2017, 12:01:33 PM
Use the "get property" action
Title: Re: Getting light component from a game object
Post by: Arnoob on March 05, 2017, 12:13:13 PM
My bad, I should've mentioned that I already tried the get property also.
I can access all the values (intensity, color, flare etc...) but I can't get the light object itself into a variable.
Title: Re: Getting light component from a game object
Post by: mdotstrange on March 05, 2017, 12:57:22 PM
Oh ok- if you want to save a variable type that PM does not support use the Object variable type- you have to set the variable type after creating the variable by usually choosing UnityEngine--> then the object type
Title: Re: Getting light component from a game object
Post by: Arnoob on March 05, 2017, 01:22:55 PM
Oh, do you mean that the only way is to create custom action? (I'm sorry I didn't exactly understood your answer, it's not my first language)
Title: Re: Getting light component from a game object
Post by: mdotstrange on March 05, 2017, 01:52:44 PM
You can create an object variable
(http://i.imgur.com/7NiSkkV.png)

Set the type to light
(http://i.imgur.com/Pi8NI47.png)

Then you can use the variable
(http://i.imgur.com/ulMApU2.png)

A custom action would be best- but you can get it with get component
(http://i.imgur.com/nhYRAAG.png)
Title: Re: Getting light component from a game object
Post by: jeanfabre on March 06, 2017, 12:41:05 AM
Hi,

 I doubt that will help you telling a script the light component, what is the api on that script? is it a method, a property?

 Bye,

 Jean
Title: Re: Getting light component from a game object
Post by: Arnoob on March 06, 2017, 05:08:44 AM
Wow mdostrange! I can't thank you enough

It's been 2 years that I started using PM, and I can't believe I didn't knew that.
Now I am able to get any component in my scenes, including a lot of custom assets that I didn't knew was possible.

@Jeanfabre : Hey how are you? It's been a while. Well mdostrange's method totally worked, I simply had to create the light object variable, use the "get component" action to store it, and put it on the post effect component using the "set property" action!

The great new is that now I will be able to do a lot of things with purchased assets I didn't knew was possible! I get back to work, I've got to see what I can get out of Aaron grandberg's pathinding knowing that method now ;-D

Cheers!
Title: Re: Getting light component from a game object
Post by: jeanfabre on March 06, 2017, 08:24:12 AM
Hi,

 Great :)

 Bye,

Jean