Community Forum

Player Position in FS2009

Forum Overview >> Farming Simulator 2009

CategoryFarming Simulator 2009
Created24.11.2009 15:36


Alex Engel (unknown) 24.11.2009 15:38
Hello to you all,
I was wondering if there is a function that will allow me to check whether the player is close to a Object and to trigger a HUD with it. If so i would be ever so grateful for the code snippet or the function that I need to do so I need to do so.



best regards

Alex

B. Benjamin (unknown) 24.11.2009 18:21
Hello Alex,

you can use this function :

local nearestDistance = 5.0; --max distance allowed
local px, py, pz = getWorldTranslation(self.rootNode); --self.rootnode is your implement
local vx, vy, vz = getWorldTranslation(Player.rootNode);
local distance = Utils.vector3Length(px-vx, py-vy, pz-vz);
if distance < nearestDistance then
self.inrange = true; --player is in range
else
self.inrange = false; --player is not in range
end;

Then use " self.inrange " as a condition to display the HUD or to allow an action. ;)

Regards,
Bayn

Alex Engel (unknown) 24.11.2009 21:22
Works like a charm, thank you very much. The rest of the script for the Center pivot I have built was easy, this was the only part that really made my head hurt.

Cheers
Alex


Alex Engel (unknown) 24.11.2009 22:21




Note: Log in to post. Create a new account here.