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 /
avatar image
0
Question by marcrem · Oct 28, 2016 at 07:51 AM · physicsrigidbodygravityforceorbit

Tornado throwing back force after pulling

Here's my scripts:

I add this script to my objects that I want to be pulled by the tornado:

 using UnityEngine;
 using System.Collections;
 
 public class PullObject : MonoBehaviour {
 
     
     public bool isClose = false;
     
 
 
 
     public void OnTriggerEnter(Collider other)
     {
         Vector3 dir = transform.position - other.GetComponent<Transform> ().position;
 
         if (other.gameObject.tag == "Tornado") {
             isClose = true;
         }
     }
 }


Then I add this script to my tornado's center:

 using UnityEngine;
 using System.Collections;
 
 public class TornadoVortex : MonoBehaviour {
 
         
     private GameObject PullOBJ;
     public float PullSpeed;
     public float objRotationSpeed;
     
 
 
     public void OnTriggerStay(Collider coll)
     {
         if (coll.gameObject.tag == "Pullable") {
             PullOBJ = coll.gameObject;
             PullObject currentObject = coll.gameObject.GetComponent<PullObject> ();
 
 
             if (currentObject.isClose == false) {
                 PullOBJ.transform.position = Vector3.MoveTowards (PullOBJ.transform.position, this.transform.position, (PullSpeed / 2) * Time.deltaTime);
                 PullOBJ.transform.RotateAround (transform.position, Vector3.up, Time.deltaTime*-20);
                 PullOBJ.transform.Rotate (Vector3.left, 45 * Time.deltaTime * objRotationSpeed);
             }
         }
 
 
 
     }
 
 
 }
 

The reason why I use tag detection is to add multiple colliders around my tornado with my script attached, but only the one at the center of it having the tag "Tornado" attached to it. This way I can put different pulling forces to my different colliders in the editor, but only the one in the center (with tornado tag) will make objects stop to be pulled.

So Basically, as long as the object has not reached the center of the tornado, it is getting moved towards it, while also being orbiting around it and rotating on itself to simulate the wind making it spin.

Now I would like to find a way to make the object fly out of the tornado, basically getting pushed out of it, but following the movement it came from, while falling to the ground due to gravity. If I use the current script, I can make it fall to the ground when isClose = 1, but it falls straight down, instead of falling slowly while still rotating a bit. Also, I need to find a way to make it pullable again as soon as it got out of the tornado radius, in case it comes back on the object.

If by any "chance" the tornado comes back on the object, it has to be pullable again.

Here's what I've done so var VS what I'm looking for : alt text

Hope anyone can help me here! THANKS SO MUCH!

help.jpg (132.3 kB)
Comment
Add comment
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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Zodiarc · Oct 28, 2016 at 02:44 PM

You could also make a more physics based approach. There are 2 forces which you have to deal with. The force which pulls the ubject towards the tornado and the centrifugal force. At first any object near the tornado could have the centrifugal force of 0 and being pulled towards the tornado. You calculate the pull force and the centrifugal force from this point on. If the centrifugal force is greater then the pull, the objects flys away. Or you could combine the two forces and at some point when the centrifugal force will be greater and switch the direction of the combined force.

Comment
Add comment · Show 2 · 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 marcrem · Oct 29, 2016 at 04:35 PM 0
Share

That's a good idea, however, I cant understand how I could add centrifugal force. Do you ?

Thanks!

Edit: oh and how could i make a mass dependent pull force?

avatar image Zodiarc marcrem · Nov 07, 2016 at 08:16 AM 0
Share

There are formulas how to calculate these things

http://www.engineeringtoolbox.com/centripetal-acceleration-d_1285.html

The pull force could be done by using the wind speed and the mass of the object. The heavier the object the harder it is for the tornado to pull it in. But I'm not good at math at all, so I can't directly answer this.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

How to make a object jump constantly at y and move to the next position to z (perfectly) 0 Answers

Gravity is preventing object from moving straight toward its direction when calling rigidbody.AddForce... 1 Answer

Artificial Gravity 2 Answers

What's the Rigidbody's gravity unit? 1 Answer

Problems making a glider 3 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