Setting Cone Angles On SpotLight
Hi, i'm trying to create some spotlights for a game i'm creating but i'm having some trouble setting the spotlights cone values when i'm trying to create them.
I get this error when i try to compile my code
But if i remove the part where is set the cone angle, i can compile and run with no issues.
This is my light creating code currently.
Am i doing something wrong when i'm creating the lights or are you not supposed to set the cone values at that point and if so, where do i set their values.
I know this is an old inquiry, but I have an answer and would like to provide it if someone else (like me) stumbles upon this post.
The linker error is due to SetOuterConeAngle() (and SetInnerConeAngle() for that matter), have been marked as deprecated when trying to call it directly from the ASpotlight object. The documentation: "BEGIN DEPRECATED (use component functions now in level script)". The guess that was made for the fix of:
will actually work. However, in order for it to actually work, you need to make sure the light is considered "movable" -- if it's not set to this, then attempting to make the change via the methods will have no effect. The code for SetOuterConeAngle() looks like this:
That check for AreDynamicDataChangesAllowed() is what is causing the change not to take because the light isn't set to be movable. So, to make it moveable, your code should read:
Then, if you want the light to be stationary again (or static), follow the above code with:
So yeah, that's it. Once you've spawned your light, make it movable, make your changes to the light, and then make it stationary again. I hope this helps someone else who runs into this issue.
answered Aug 30 '18 at 10:33 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here