// Use this for initialization void Start() { explosiveForce = 100.0f; explosionRadius = 5.0f; GameObject ball = GameObject.Find("Ball"); move = ball.GetComponent <MoveSphere>(); particle = GameObject.Find("SparkEmitter"); }
void Start() { spawnPoint = GameObject.Find("Spawn Point: Start").transform; if (!(sphereMover = GetComponent <MoveSphere>())) { Debug.LogError("Unable to find sphere movement script"); } }
public static bool Test_Moving_Spheres(MoveSphere s1, MoveSphere s2) { //momentum exei provlima an provlepseis me velocity //tote paei sosta ok //alla epeidi prin kaneis to update to teliko kanei sthn epomenh provlepsi //den exei trexei endiamesa convert //ki prokyptei provlima giati xanapas me ta palia var sep = s2.sphere.Position - s1.sphere.Position; var r = s2.sphere.Radius + s1.sphere.Radius; var vrel2 = -s1.Velocity; var vrel1 = -s2.Velocity; var rel = vrel2 - vrel1; var velax = Vector3.Dot(rel, sep); var c = sep.LengthSquared() - r * r; if (velax >= 0f) { return(false); } var a = rel.LengthSquared(); var b = velax; if (c < 0f) /*throw new Exception();*/ return { (false); } if (a < 0.000001f) { return(false); } //akinites relatively var d = b * b - a * c; if (d < 0) { return(false); } else { var time = (float)(((-b - Math.Sqrt(d)) / a)); if ((time >= 0.016f) || (time <= 0)) { return(false); } else { return(true); } } }
public static bool Test_Moving_Spheres(MoveSphere s1, MoveSphere s2) { //momentum exei provlima an provlepseis me velocity //tote paei sosta ok //alla epeidi prin kaneis to update to teliko kanei sthn epomenh provlepsi //den exei trexei endiamesa convert //ki prokyptei provlima giati xanapas me ta palia var sep = s2.sphere.Position - s1.sphere.Position; var r = s2.sphere.Radius + s1.sphere.Radius; var vrel2 = -s1.Velocity; var vrel1 = -s2.Velocity; var rel = vrel2 - vrel1; var velax = Vector3.Dot(rel, sep); var c = sep.LengthSquared() - r * r; if (velax >= 0f) { return false; } var a = rel.LengthSquared(); var b = velax; if (c < 0f) { /*throw new Exception();*/ return false; } if (a < 0.000001f) { return false; }//akinites relatively var d = b * b - a * c; if (d < 0) { return false; } else { var time = (float)(((-b - Math.Sqrt(d)) / a)); if ((time >= 0.016f) || (time <= 0)) { return false; } else { return true; } } }
// Use this for initialization void Start() { player = GameObject.FindGameObjectWithTag("Player").transform; control = player.GetComponent <MoveSphere>(); targetPosition = new Vector3(player.position.x, player.position.y + 10, player.position.z - 10); }