Page MenuHomeFeedback Tracker

ModelToWorld in Car is not Correct
Closed, ResolvedPublic

Description

in Example 4 objects around the player.

When the player was on the floor is all right. If the player is in a vehicle which objects are in front of him in the bottom countersunk, werend the objects behind him hanging in the air. Just the Right and Left are on the height of the player.

Details

Legacy ID
395472275
Severity
None
Resolution
No Bug
Reproducibility
Always
Category
Scripting
Steps To Reproduce

{_obj = (_x select 0) createvehicle [0,0,0];
_obj setPos ( player modelToWorld [(_x select 1) select 0,(_x select 1) select 1,0] );
_obj setDir ( (getDir player) - (_x select 2) ); } forEach [["Land_HBarrierBig_F",[-5.09961,-26,0],0],["Land_HBarrierBig_F",[-35.5996,3.10059,0],90],["Land_HBarrierBig_F",[4.90039,33,0],0], ["Land_HBarrierBig_F",[41.9004,4.2002,0],90]];

Event Timeline

Nokman edited Steps To Reproduce. (Show Details)Nov 14 2014, 5:46 PM
Nokman edited Additional Information. (Show Details)
Nokman set Category to Scripting.
Nokman set Reproducibility to Always.
Nokman set Severity to None.
Nokman set Resolution to No Bug.
Nokman set Legacy ID to 395472275.May 7 2016, 7:50 PM

modelToWorld takes into account vectorUp of the object. While on foot player's vectorUp is [0,0,1], when in vehicle it can be different, tilted forward a bit like in your case.

player setVectorUp [0,0,1];
{_obj = (_x select 0) createvehicle [0,0,0];
_obj setPos ( player modelToWorld [(_x select 1) select 0,(_x select 1) select 1,0] );
_obj setDir ( (getDir player) - (_x select 2) ); } forEach [["Land_HBarrierBig_F",[-5.09961,-26,0],0],["Land_HBarrierBig_F",[-35.5996,3.10059,0],90],["Land_HBarrierBig_F",[4.90039,33,0],0], ["Land_HBarrierBig_F",[41.9004,4.2002,0],90]];

does the trick already, but I suggest you reference the actual vehicle

vehicle player

which should work for both on foot and in vehicle

{_obj = (_x select 0) createvehicle [0,0,0];
_obj setPos ( vehicle player modelToWorld [(_x select 1) select 0,(_x select 1) select 1,0] );
_obj setDir ( (getDir vehicle player) - (_x select 2) ); } forEach [["Land_HBarrierBig_F",[-5.09961,-26,0],0],["Land_HBarrierBig_F",[-35.5996,3.10059,0],90],["Land_HBarrierBig_F",[4.90039,33,0],0], ["Land_HBarrierBig_F",[41.9004,4.2002,0],90]];

EDIT minus vehicle height offset. 1st method is probably better.