Hello-
I keep getting a NaN error for certain variables(ph3, angleradians, and angle) in this script. I suspect the reason is that because both ph3 and angle are linked to angleradians, they cannot calculate the answer. Angleradians uses Mathf.Asin, but I cannot find what I did wrong. Any ideas?
#pragma strict
var shell:GameObject;
var self:GameObject;
var distance:float;
var ph1:float;
var ph2:float;
var ph3:float;
var angleradians:float;
var velocity = 240;
var angle:float;
var target:Transform;
function Update(){
distance = Vector3.Distance(target.position,transform.position);
//-----------------------------------------------------------------------
ph1 = distance*9.81;
ph2 = ph1/velocity;
angleradians = Mathf.Asin(ph2);
ph3 = angleradians * 3.14;
angle = ph3/180;
var currentrot = self.transform.rotation.x;
var requiredangle:float;
var requiredrot = currentrot - angle;
self.transform.eulerAngles.x = requiredangle;
Instantiate (shell, self.transform.position, self.transform.rotation);
}