|Category||Farming Simulator 2009|
|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.
|B. Benjamin (Unknown)||24.11.2009 18:21|
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
self.inrange = false; --player is not in range
Then use " self.inrange " as a condition to display the HUD or to allow an action. ;)
|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.
|Alex Engel (Unknown)||24.11.2009 22:21|
Note: Log in to post. Create a new account here.