• 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 t$$anonymous$$s 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 t$$anonymous$$s 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, t$$anonymous$$s.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. T$$anonymous$$s 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, w$$anonymous$$le 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, w$$anonymous$$le 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 w$$anonymous$$le 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 w$$anonymous$$ch you have to deal with. The force w$$anonymous$$ch 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 t$$anonymous$$s 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
avatar image Zodiarc marcrem · Nov 07, 2016 at 08:16 AM 0
Share

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.

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

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

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

Artificial Gravity 2 Answers

How to make a object jump constantly at y and move to the next position to z (perfectly) 0 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