zjy6400 Posted February 28, 2012 Share Posted February 28, 2012 I am working on some kind of script that when it triggers it will calculate the distance between the target and the player,by what means can I make it?I've tried Game.FindClosestReferenceOfTypeFromRef(target,player,radius),but it always return none regardless the radius I set Link to comment Share on other sites More sharing options...
Cipscis Posted February 28, 2012 Share Posted February 28, 2012 FindClosestReferenceOfTypeFromRef takes an object of type Form as its first parameter, which should be the base object of which you're trying to find references. However, I suspect your "target" variable is of type ObjectReference, which is itself a reference. Since ObjectReferences can't have references of their own, FindClosestReferenceOfTypeFromRef will never find anything, but because ObjectReference extends Form the compiler will auto-cast it to Form so the compilation will be successful. To fix your call to FindClosestReferenceOfTypeFromRef, you'll need to use GetBaseObject in order to your target's base form. To calculate the distance between two references, however, you don't want to use this function. Instead, you want to use the GetDistance function. Cipscis Link to comment Share on other sites More sharing options...
Recommended Posts