ajs52698 Posted July 30, 2016 Share Posted July 30, 2016 So im trying to make a script that programs a npc to actively search for nearby object and go to them. My problem is when using the command Player.translatetoref, when specifying the location I want the npc to move to I need it to automatically use the object that the npc has found that is closest to it. So player.translatetoref( The location is automaticly retrieved,100) Link to comment Share on other sites More sharing options...
Dielos Posted July 31, 2016 Share Posted July 31, 2016 You could use FindClosestReferenceOfTypeFromRef() for this. But using TranslateToRef will have your NPC floating to the target reference, not walking. You might need to use packages for this. Just for the sake of the example, with TranslateToRef, you could do something like this: Function MoveMyNPC() ObjectReference ClosestObj = Game.FindClosestReferenceOfTypeFromRef(ObjToSearch, Game.GetPlayer(), 1500.0) If ClosestObj != none Debug.Notification("Object found and starting movement...") MyNPC.TranslateToRef(ClosestObj, 90.0) Else Debug.Notification("Nothing Found") EndIf EndFunction FindClosestReferenceOfTypeFromRef looks for BaseID's or for a FormList with BaseID's inside. Link to comment Share on other sites More sharing options...
ajs52698 Posted August 1, 2016 Author Share Posted August 1, 2016 alright thanks ill look into using that Link to comment Share on other sites More sharing options...
Recommended Posts