# Tornado physics

Right know im building a tornado but i cant figure out how to add physics to it. The forces i need are:

• Force 1 is a suction force that makes the stuff move towards the tornado
• Force 2 is a rotation force to make the stuff spin around the tornado, which I apply perpendicular to the center of the tornado
• Force 3 is a lift force to make the stuff move up
• Force 4 is a centrifugal force to make the stuff move away from the tornado
Im not really familliar with c# scripting because im still a bit of a beguinner. So please let me know how to add these forces to my tornado.

I am currently making a tornado simulation. Check out vectoraygen.

well for the suction part you can watch this video.
Click here to watch

cool i can use that for suction, now i just need the other 3

This script slowly drags a object at a certain range and also rotates it when it interacts with the tornado object:

``````    //Float used to set the speed of the suction of the tornado
public float pullInSpeed = 0.1f;

//Float used to set the speed of the rotation of the tornado
public float rotateSpeed = 1.25f;

//Radius the suction of the tornado reaches
public float radius = 20;

//Holds the objects within the radius
public List<GameObject> objectsToPullIn;

//Sets whether the objects is being pulled or not
public Dictionary<GameObject, bool> objectsPulled;

void Start()
{
//Instantiate Dictionary and List for use
objectsToPullIn = new List<GameObject>();
objectsPulled = new Dictionary<GameObject, bool>();
}

void RemoveObjectsFarAway()
{
//For each of the gameobjects in objectsToPullIn
foreach (GameObject thing in objectsToPullIn)
{
//Check if the distance between the objects position and the tornados position is greater than the suctions radius
if (Vector3.Distance(thing.transform.position, transform.position) > radius)
{
//And if that is true then remove the object from being sucked in
objectsToPullIn.Remove(thing);
}
}
}

void GetObjectsToPullIn()
{
Collider[] objects = Physics.OverlapSphere(GetComponent<Collider>().bounds.center, radius);//GetComponent<Collider>().bounds.extents.magnitude);
//For each object
for (int i = 0; i < objects.Length; i++)
{
//If that object is not already contained in the objectsToPullIn list
//the object does not equal the tornado, and if it contains a
//rigidbody component
if (!(objectsToPullIn.Contains(objects*.gameObject))*
``````

&& objects*.gameObject != gameObject*
&& objects*.GetComponent() != null)*
{
//Then add it to the objects to pull in list
objectsToPullIn.Add(objects*.gameObject);*
//And make sure to set that the object has not been pulled all the way in yet
objectsPulled.Add(objects*.gameObject, false);*
}
}
}

void PullObjectsIn()
{
//For each gameobject in objectsToPullIn
foreach (GameObject thing in objectsToPullIn)
{
//If the object has been pulled in
if (objectsPulled[thing] != true)
{
//Then move it towards the tornado
thing.transform.position = Vector3.MoveTowards(thing.transform.position, transform.position, thing.GetComponent().mass * Time.deltaTime * pullInSpeed);
}
}
}

void RotateObjects()
{
//For each of the gameobjects that have been classified as being pulled in or not
foreach (GameObject thing in objectsPulled.Keys)
{
//If they are pulled in
if (objectsPulled[thing] == true)
{
//Then rotate it around the tornado
thing.transform.RotateAround(Vector3.zero, transform.up, thing.GetComponent().mass * rotateSpeed * Time.deltaTime);
}
}
}

void OnCollisionEnter(Collision other)
{
//If the object is contained in the object to pull in list
if (objectsToPullIn.Contains(other.gameObject))
{
//Then set the object as being pulled in to the tornado
objectsPulled[other.gameObject] = true;
//Rotate that shit
RotateObjects();
}
}

void OnCollisionStay(Collision other)
{
//If the object is contained in the object to pull in list
if (objectsToPullIn.Contains(other.gameObject))
{
//Then set the object as being pulled in to the tornado
objectsPulled[other.gameObject] = true;
//Rotate that shit
RotateObjects();
}
}

void OnCollisionExit(Collision other)
{
//If the object is contained in the object to pull in list
if (objectsToPullIn.Contains(other.gameObject))
{
//Then set the object as not being pulled in to the tornado
objectsPulled[other.gameObject] = false;
}
}

void Update()
{
//Each update:

//Run these methods
RemoveObjectsFarAway();
GetObjectsToPullIn();
PullObjectsIn();
RotateObjects();
}
Hopefully this stuff helps out a little bit. I mean all it does is pull the objects in and rotate them when they are in contact with the tornado.