track to question

I’m sure there is a quick answer to this but…does the ‘track to’ actuator not work on lamps? I was trying to track an object with the sun lamp and it does not seem to be working…

If it does not work I will have to attach the ‘sun’ to another object and have it track to the object I was trying to track.

It does work on lamps. You might just have the axis set up wrong.

I am having a hard time because I am trying to track it’s -z axis to an object that is also aligned on the z axis I think…

so z = up, and track to -z…but it is fighting me…it does not want to cooperate…I’ll get it. Knowing that it works from a more experienced user just helps me to know I just need to keep at it…

ok, got it…it did not work with the actuator though…the actuator assumes the orientations are not in line like mine…the following worked fine though…


v1 = sun.worldPosition - own.worldPosition
v2 = sun.getVectTo(v1)
sun.alignAxisToVect(v1,2,1)

I was working on my world lighting…loop through lights and disable them if they are out of distance x
and ofc the sun cycle…was also a PITA…I cringe when I need to work with radians…they are fine, but feel foreign…luckily I found the math.radians() function…

If you change the “up” axis to something else, then it should start working.

I am curious as to how you disable the lights. Setting their energy to zero does not make them consume any less GPU time. Nor does deleting them. Lights (in the current version of BGE) are compiled in to the shaders, and they cannot be created or destroyed without recompiling the shaders (which is relatively slow to do). As far as I know, the only way to handle lights in BGE is to use placeholders and move a finite set of actual lights around.

Radians are amazing and wonderful, but yes, they do take a while to get used to. Perhaps when you realise the reason for them they may make a bit more sense.
Everyone introduces radains by saying “there are 2pi radians in a circle” - but the far more useful think to know is: what is one radian? The answer is that one radian is the angle to rotate through where the circumference (of the bit you rotated by) is equal to the radius. This means that if you have a wheel 12cm radius, and you rotates 10 radians, then you travelled 120cm. Same with velocity. If you have a wheel 12cm, and are rotating at 5 radians per second, then the velocity at the edge of the wheel is 60cm/s (12 * 5). Magic.

you lost me at “radians are amazing” :)…I understand, but degrees are much quicker to comprehend since that is how we learn as children on up…it is harder to un-learn something than it is to learn something from scratch.

as far as the lights go…I have not disabled them…I guess I was wrong, but I made an assumption that when they do not contribute to the scene lighting they are automagically disabled…I had not thought of moving them…maybe to an empty layer…that is a pretty good idea…I’m glad you mentioned it.

I believe* someone had discovered to remove a light permanently, it needs to have a parent and when you remove it’s parent instead, the light will be freed from the scene, why it works remains a mystery

@guramarx:
I’m sceptical of that. Compiling the shaders is not a quick process, as can be seen if you are on a slow machine and change a setting in one of the lights. So if a light is being fully removed, there will be some lag while removing it…
However, in future versions of UPBGE (ie the eevee branch at the moment) they are doing away with this limitation as they are transferring lights in a UBO, and that means the lighting of the scene can be updated independently of compiling the shaders. When that happens, lighting in BGE will get a lot more awesome.

@sdfgeoff
Thanks for the info and I see what you mean, but for now that’s the only work around to add/remove light without spiking the rasterizer

you can parent a light to an object(think unity prefab(I use empties)) and stick it on another layer…you can delete them(endObject) and add them(addObject)…works fine and that is how I started to do it in my light manager. the only permanent light is the sun…only because it is tied to my world empty(the object with world script attached)…but I am thinking of a good solution(hopefully :))for that too…

Things do not have to be complex to work well…matter of fact, I find just the opposite to be true.