Jump to content
Sign in to follow this  
chronicsilence

Attached Lights bouncing around

Recommended Posts

Hi everyone,

I'm creating lights to attach to a vehicle (emergency lights), using the following script:

_newlight = "#lightpoint" createVehicle [100000,100000,100000];

_newlight setLightColor [1,1,1];

_newlight lightAttachObject [_vehicle, [-0.45, 0.0, 0.56]];

This is a simplified version, but you get the point. The light shows up in the correct spot and functions properly when the vehicle is stopped. However, as soon as the vehicle starts moving, the light bounces around on the vehicle and doesn't stay in its attached location. Once the vehicle stops again, it returns to its correct location. Anyone know why?

Share this post


Link to post
Share on other sites

I found that the regular attachTo command works at least a bit better than "lightAttachObject".

You'll still get some bouncing though.

Share this post


Link to post
Share on other sites

Like I said, attachTo helps to some extend.

Only other workaround I can think of would be to update the position of the light manually on each frame with modelToWorld. Though that would be a bit resource intensive.

Edited by Tajin

Share this post


Link to post
Share on other sites

i had (have) the same problem on my Mohawk script (in my sign), seem to be how the engine handles lights, probably no way...

Share this post


Link to post
Share on other sites

Only other workaround I can think of would be to update the position of the light manually on each frame with modelToWorld. Though that would be a bit resource intensive.

Very expensive, plus I think they must be local, for use in multiplayer you should use BIS_fnc_MP to create them on each computer

Share this post


Link to post
Share on other sites
Very expensive, plus I think they must be local, for use in multiplayer you should use BIS_fnc_MP to create them on each computer

Wouldn't they be local though? If a function is run using BIS_fnc_MP, then that function will be run on every computer. If the function is run on every computer, then that function should create local lights. If you create global lights on each computer, well now you've created 'NUM LIGHTS' * 'NUM PLAYERS'.

Share this post


Link to post
Share on other sites
Like I said, attachTo helps to some extend.

Only other workaround I can think of would be to update the position of the light manually on each frame with modelToWorld. Though that would be a bit resource intensive.

Hilariously enough, this doesn't even work. It looks like the engine doesn't provide accurate position data on the vehicle every frame, so even if I force the position every frame, I can't force it to the proper location because I can't GET the exact proper location of the vehicle.

EDIT: ok, I have more info on how this works. The modelToWorldVisual command will get the current, interpolated position of the vehicle with the given offset. However, using the setPos function with that position onEachFrame will still cause the jitter because the light's position isn't interpolated every frame like the vehicle is. So, what I need is a way to force the light's position to be updated every render frame instead of every simulation step. Similar to how the drawIcon3D function works.

Edited by ChronicSilence

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×