// void Update() { yint = fx.output(0); for (int i = 0; i < range; i++) { double xpos = (divider) * (i - (int)(range / 2)); double ypos = fx.output(xpos); if (!(Double.IsNegativeInfinity(ypos) || Double.IsInfinity(ypos) || Double.IsNaN(ypos) || ypos > 100 || ypos < -100)) { pointGuide[i].transform.localPosition = new Vector3((float)xpos, 1.5f, (float)ypos); } } }
// Update is called once per frame void FixedUpdate() { rb.position = new Vector3((float)(rb.position.x + (dir * amount)), rb.position.y, (float)(initPos.z + fx.output((dir * amount) + rb.position.z - initPos.z))); }
private void Visualize() { // delete previous visualize projectiles, set last equation, set the appropriate function lastEquation = inputField.text; functionControlScript.SetFunction(inputField.text); int visualizeProjectileIndex = 0; // visualize the positive projectile (the one that travels right) bool positiveWorking = true; for (int frames = 0; frames < visualizerMaxFrames; frames++) { GameObject currentVisualizeProjectile = visualizeProjectileInstants[visualizeProjectileIndex]; if (positiveWorking) { float output = (float)functionControlScript.output(frames * visualizerSpeed); if (float.IsNaN(output) || float.IsInfinity(output)) { positiveWorking = false; } else { currentVisualizeProjectile.SetActive(true); currentVisualizeProjectile.transform.position = new Vector3(transform.position.x + frames * visualizerSpeed, transform.position.y + playerHeight, transform.position.z + output); } } if (!positiveWorking) { currentVisualizeProjectile.SetActive(false); } visualizeProjectileIndex++; } // visualize the negative projectile (the one that travels left) bool negativeWorking = true; float zeroOutput = (float)functionControlScript.output(0); if (!float.IsNaN(zeroOutput) && !float.IsInfinity(zeroOutput)) { for (int frames = 1; frames < visualizerMaxFrames; frames++) { GameObject currentVisualizeProjectile = visualizeProjectileInstants[visualizeProjectileIndex]; if (negativeWorking) { float output = (float)functionControlScript.output(-frames * visualizerSpeed); if (float.IsNaN(output) || float.IsInfinity(output)) { negativeWorking = false; } else { currentVisualizeProjectile.SetActive(true); currentVisualizeProjectile.transform.position = new Vector3(transform.position.x - frames * visualizerSpeed, transform.position.y + playerHeight, transform.position.z + output); } } if (!negativeWorking) { currentVisualizeProjectile.SetActive(false); } visualizeProjectileIndex++; } } }