• 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 /
  • Help Room /
avatar image
0
Question by blutackboy · Jan 16, 2016 at 04:26 PM · physicsgravityflyingthrust

wing suit physics

Hi I'm fairly new to scripting and I'm wondering how i would achieve "wing suit" physics (3d), as in you gain speed by facing downwards (more than 20 degrees - max is 90 due to camera), lose speed slowly by flying straight, lose speed quickly by flying upwards (more than 20 degrees - max 90) and then when speed is at 0 gravity starts pulling the character down (just like how a glider works)? I found a link to this: http://docs.unity3d.com/ScriptReference/Rigidbody.AddRelativeForce.html and i think this is what i need but instead of a set speed it will obviously need to be increasing and decreasing the thrust of my character based on my cameras x axis rotation. I guess what i need to to check is weather or not the angles or greater than or less than the above angles then applying the right amount of thrust I just don't no how I go about doing this, anyway, any help will be appreciated :D

Comment
Add comment · 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 blutackboy · Jan 18, 2016 at 04:13 AM 0
Share

I've done some research and this is the code i have (far from finished) and i have some problems.... 1) I can only move along the x and z axis not y 2) Once i start moving in one direction I cant look somewhere else and start moving there, I have to look downwards to speed up (slightly facing the direction i want to go while looking down)

 using UnityEngine;
 using System.Collections;
 
 public class SpeedUp : $$anonymous$$onoBehaviour {
     public Transform target;
     public float thrust;
     public Rigidbody rb;
     void Update() {
         Vector3 targetDir = target.position - transform.position;
         Vector3 forward = transform.forward;
         float angle = Vector3.Angle(targetDir, forward);
         if (angle < 5.0F)
             rb.AddRelativeForce(Vector3.forward * thrust);
         
     }
 }

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Zenvin · Jun 07, 2017 at 03:56 PM

To check the angle, you could use "transform.eulerAngles.x". So you can do something like this:

float speed = 10f;

void Update () {

float currX_Angle = transform.eulerAngles.x;

if (currX_Angle < 90 && currX_Angle > 20) {

speed = 15f;

}

if(currX_Angle <= 20 && speed > 0) {

speed -= 1f

}

}

}

Then you can add the force multiplied by the speed and any other factor to the object's rigidbody.

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.

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

Non-centered gravity 0 Answers

Changing gravity depending on character/camera rotation 0 Answers

Physics for ball on an incline: rolling up a hill if half way up 1 Answer

Unity Faux gravity on a cube: reaching some faces is troublesome 0 Answers

Rigidbodys velocity resets to 0 upon reaching -11 while falling close to another object 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