Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 nhftk12 · Jan 07, 2012 at 09:15 AM · planewindwhere-to-start

glide with the wind.

I'm building a game witch you throw a paper planes to a target. For the plane throwing I used rigidbody.AddForce.

I trying to add a wind that will affect the plane when it flying and I don't know where to start or if it even posible.

Does anyone can help me with it? Sorry for poor english.

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

4 Replies

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by Lo0NuhtiK · Jan 07, 2012 at 09:44 AM

You could use trigger collider areas to set something like a wind zone up.
wind force on character controller take a look at the stuff on there and adapt those ideas to your plane rather than using character controller.



EDIT :


Heres something to get you started.

Add this to you're paper-plane's movement script. ->

private var myRigid : Rigidbody ; //used to cache the planes rigidbody private var inWind : boolean = false ; @HideInInspector var windScript : WindScript ; var windObjectTag : String = "MyWindObjectsTag" ; //set this in the inspector to //whatever you tag your wind object as

  //if you have a start() function, add this to it ; make one if you don't function Start(){ myRigid = rigidbody ; }   //if you have your plane movement in FixedUpdat() , add this to that area function FixedUpdate(){ if(inWind && windScript!=null){ //if we're in the wind BlowMe(); } }   function BlowMe(){ myRigid.AddForce(windScript.wind) ; //add force from the windscript }   //if you have on ontriggerenter() on your plane already, just add this to it function OnTriggerEnter(hit : Collider){ if(hit.collider.CompareTag(windObjectTag)){ inWind = true ; windScript = hit.gameObject.GetComponent(WindScript) as WindScript ; } }   //if you have ontriggerexit on your plane already, add this to that function function OnTriggerExit(hit : Collider){ if(hit.collider.CompareTag(windObjectTag)){ inWind = false ; windScript = null ; } }


Now, make a new Empty game Object... name it whatever, then tag it whatever you want your wind to be tagged as, and make sure you set on the inspector the script above to be looking for that tag in 'windObjectTag' ...
Give that empty object a primitive collider (sphere,box,etc) and size it however large you want your windzone to be. Mark it's collider as 'isTrigger' in the checkbox.
Make a new javascript file. Name it "WindScript". Add this single line to the WindScript ->

var wind : Vector3 ; 

.... now, attach that script to your new empty wind object you just made, then in the inspector set the variable values of 'wind' on whatever axis with whatever force etc...
Repeat this as necessary for however many windzones you want with whatever forces etc you want them to have.
Note : the 'wind' will be adding force in global/world relation, NOT in relation to your object/plane's local rotation.

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 nhftk12 · Jan 07, 2012 at 10:00 AM 0
Share

I'm not using character controller, only rigidbody.

avatar image nhftk12 · Jan 07, 2012 at 12:35 PM 0
Share

It works! Thank you very much!

avatar image
0

Answer by broesby · Oct 18, 2012 at 05:36 PM

Hi there,...

This script is what I really need. I'm afraid I don't know much about coding, but I learn as I go along.

Problem is I keep getting a compiler error. I think I did exactly as written.

I appended the script to the default CharacterMotor script as said.

But the compiler keep saying that "the name WindScript does not denote a valid type (not found)". I did add the windscript named WindScript as mentioned to an empty gameobject wit a box collider. I also added a custom tag: "Wind" to that object and put Wind in the original script snippet above.. Sry, but I don't know what I do wrong :(

Comment
Add comment · 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 broesby · Oct 18, 2012 at 05:36 PM

Hi there,...

This script is what I really need. I'm afraid I don't know much about coding, but I learn as I go along.

Problem is I keep getting a compiler error. I think I did exactly as written.

I appended the script to the default CharacterMotor script as said.

But the compiler keep saying that "the name WindScript does not denote a valid type (not found)". I did add the windscript named WindScript as mentioned to an empty gameobject wit a box collider. I also added a custom tag: "Wind" to that object and put Wind in the original script snippet above.. Sry, but I don't know what I do wrong :(

Comment
Add comment · 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 kskjadav007 · Feb 08, 2018 at 12:38 PM

I m Stuck in Rotation Of Plane

 Vector3 dir = m_Rb.velocity;
 
 //Debug.Log (""+dir);
 
 float angle = Mathf.Atan2(dir.y, dir.x) * Mathf.Rad2Deg;
 
 transform.rotation = Quaternion.AngleAxis(angle, Vector3.forward);


with this i m geting rotation but not correct , thanks

Comment
Add comment · 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

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

7 People are following this question.

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

Related Questions

What is Vector3.Exclude for? 2 Answers

i've messed something up 1 Answer

hot to use raycast 2 Answers

Camera project to plane 1 Answer

Invisible wall blocking rendering in a area. 1 Answer


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