Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
This question was closed Aug 15, 2018 at 12:08 PM by Bunny83 for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by Jdogmaster · Mar 23, 2018 at 12:59 AM · c#physicsparticlesparticle systemc# tutorial

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.

Comment
Comments Locked · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image meat5000 ♦ · Mar 31, 2018 at 05:33 PM 0
Share

As this is the Third time youve posted this question, Ive deleted the others. Stop duplicate posting : - This is a warning.

4 Replies

  • Sort: 
avatar image
0
Best Answer

Answer by KittenSnipes · Mar 24, 2018 at 01:46 AM

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[i].gameObject)) 
                 && objects[i].gameObject != gameObject
                 && objects[i].GetComponent<Rigidbody>() != null)
             {
                 //Then add it to the objects to pull in list
                 objectsToPullIn.Add(objects[i].gameObject);
                 //And make sure to set that the object has not been pulled all the way in yet
                 objectsPulled.Add(objects[i].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<Rigidbody>().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<Rigidbody>().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.

Comment
Comments Locked · Show 67 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Jdogmaster · Mar 24, 2018 at 01:48 AM 0
Share

Sweet ya I will try it out right away! Let u know how it oges

avatar image KittenSnipes Jdogmaster · Mar 24, 2018 at 01:50 AM 0
Share

@Jdogmaster

Hopefully it helps :D

avatar image Jdogmaster · Mar 24, 2018 at 01:50 AM 0
Share

Btw do i need to add a script to the object?

avatar image KittenSnipes Jdogmaster · Mar 24, 2018 at 01:51 AM 0
Share

Add the script to the tornado object

avatar image Jdogmaster · Mar 24, 2018 at 01:55 AM 0
Share

So how do i get objects to react to the tornado, I added the script to the tornado but the tornado just dissapeared and the object didnt move? Do i need to add a script to the objects? @$$anonymous$$ittenSnipes

avatar image KittenSnipes Jdogmaster · Mar 24, 2018 at 01:57 AM 0
Share

Im going to send a video. $$anonymous$$aybe that can help

avatar image KittenSnipes Jdogmaster · Mar 24, 2018 at 01:59 AM 0
Share

@Jdogmaster

Here be the video:

That Tornado Vid

avatar image Jdogmaster · Mar 24, 2018 at 02:01 AM 0
Share

Thanks so much man ur the best! i will watch it right away!

avatar image KittenSnipes Jdogmaster · Mar 24, 2018 at 02:03 AM 0
Share

No problem :D

avatar image KittenSnipes KittenSnipes · Mar 24, 2018 at 02:07 AM 0
Share

Ok sure I will check it out when it is sent :D

avatar image Jdogmaster · Mar 24, 2018 at 02:06 AM 0
Share

Wait sorry i know im a noob, but when i added the script it didnt pull up the like pull factor and rotation factors so i think i did something wrong ill send a screen shot in a sec so u can let me know if i did it right

Show more comments
avatar image
0

Answer by marcrem · Mar 23, 2018 at 09:04 PM

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

Comment
Comments Locked · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by bhavinbhai2707 · Mar 23, 2018 at 09:15 PM

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

Comment
Comments Locked · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by Jdogmaster · Mar 23, 2018 at 09:18 PM

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

Comment
Comments Locked · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Follow this Question

Answers Answers and Comments

500 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Multiple Cars not working 1 Answer

Application.LoadLevel and particle system 1 Answer

Unity 5.3.4 - Particles from Prefab will not instantiate. 0 Answers

Laser beam using particle system Unity2d. 0 Answers

Can someone tell me how to make a particle system play when hitting an animal? 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges