- Home /

# whats dynamics of the playerball based on differential equations

Hey...

What do they mean by below :

The dynamics of the players based on differential equations of my original work has been implemented in the video game ?

Thanks!!!!

**Answer** by Julien-Lynge
·
Jul 18, 2012 at 03:48 PM

Differential equations are equations where the change in value of the equation at any time relies on the value of the equation at that time. For instance, for a ball moving through air, the *change in speed* (due to drag) is dependent on the *current speed* of the ball - the faster it's going, the more drag there will be. These equations are continuous (what happens next relies on what was happening an instant ago), and so are notoriously tricky to try and solve using *discrete* methods, e.g. by updating the speed only 60 times per second. Unfortunately, that's the way video game engines work - they aren't built to solve continuous math problems.

If you want to know more about differential equations, you can check out Wikipedia or any sufficiently advanced math textbook. Be warned that if you haven't had multiple semesters of foundational math like calculus you probably won't get very far.

@Julien : thanks for the reply.......below is the code that i am using for my enemy ball....how can implement the differential equations in the below code.

# pragma strict

var Speed= 10; var wayPoint : Vector3;

function Start(){ //initialise the target way point Wander(); }

function Update() { // this is called every frame // do move code here transform.position += transform.TransformDirection(Vector3.forward)*Speed*Time.deltaTime; if((transform.position - wayPoint).magnitude < 3) { // when the distance between us and the target is less than 3 // create a new way point target Wander();

```
// don't need this
//transform.LookAt(wayPoint);
//transform.position += transform.TransformDirection(Vector3.forward)*Speed*Time.deltaTime;
}
```

}

function Wander() { // does nothing except pick a new destination to go to wayPoint= Random.insideUnitSphere *12; wayPoint.y = 0.7; // don't need to change direction every frame seeing as you walk in a straight line only transform.LookAt(wayPoint); //Debug.Log(wayPoint + " and " + (transform.position - wayPoint).magnitude); }

Thanks!!!!

Code that I'm using :

# pragma strict

var Speed= 10; var wayPoint : Vector3;

function Start(){ //initialise the target way point Wander(); }

function Update() { // this is called every frame // do move code here transform.position += transform.TransformDirection(Vector3.forward)*Speed*Time.deltaTime; if((transform.position - wayPoint).magnitude < 3) { // when the distance between us and the target is less than 3 // create a new way point target Wander();

```
// don't need this
//transform.LookAt(wayPoint);
//transform.position += transform.TransformDirection(Vector3.forward)*Speed*Time.deltaTime;
}
```

}

function Wander() { // does nothing except pick a new destination to go to wayPoint= Random.insideUnitSphere *12; wayPoint.y = 0.7; // don't need to change direction every frame seeing as you walk in a straight line only transform.LookAt(wayPoint); //Debug.Log(wayPoint + " and " + (transform.position - wayPoint).magnitude); }

Two issues: first, you need to format your code. $$anonymous$$ake sure that every line of code has 4 spaced in front of it, then UnityAnswers will nicely format it.

Second, you haven't told me what the differential equation is that you want to integrate into your code.

@Julien.Lynge :

formatted code:

# pragma strict

```
var Speed= 10;
var wayPoint : Vector3;
function Start(){
//initialise the target way point
Wander();
}
function Update()
{
// this is called every frame
// do move code here
transform.position += transform.TransformDirection(Vector3.forward)*Speed*Time.deltaTime;
if((transform.position - wayPoint).magnitude < 3)
{
// when the distance between us and the target is less than 3
// create a new way point target
Wander();
// don't need this
//transform.LookAt(wayPoint);
//transform.position += transform.TransformDirection(Vector3.forward)*Speed*Time.deltaTime;
}
}
function Wander()
{
// does nothing except pick a new destination to go to
wayPoint= Random.insideUnitSphere *12;
wayPoint.y = 0.7;
// don't need to change direction every frame seeing as you walk in a straight line only
transform.LookAt(wayPoint);
//Debug.Log(wayPoint + " and " + (transform.position - wayPoint).magnitude);
}
```

Second Point: the concept is to move the ball with certain speed around a circle & when it hits the player should one of the 3 lives.

### Your answer

### Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

### Follow this Question

### Related Questions

rigid body Clone Instance not behaving like original 1 Answer

General construction of kinematic trees with scaled capsules 0 Answers

Switching between one or more cameras in the same scene? 2 Answers

How to calculate the distance of an object with velocity? 1 Answer

Reading datas from sound files 2 Answers