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 George_1999 · Mar 24, 2015 at 06:10 PM · terrainnormalgroundalignhovercraft

C# - Wipeout style Hovercraft effect

Greetings guys , I've been trying to archieve a hovercraft effect like shown in this video below for quite some time now : https://www.youtube.com/watch?v=3xWfBgtI_BA i want it to stay on the ground and be aligned to the surface below it and not go too far away from it but i can't get it to stay on the ground no matter what i try . it either flips over or it goes flying and takes ages to come back down. i'm using a rigidbody so i can't align it to the ground normal directly using the transform class . Please answer if you have any idea how to recreate this effect i've been stuck on this one for a long time and it's getting on my nerves

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

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by Cherno · Mar 25, 2015 at 10:06 AM

There's a buyonacy script designed for boats and other floating objects on water over on the forums, maybe it can serve as the base for your own script.

To keep the craft aligned to the ground at all times, ust cast a ray downward (in world space) and slowly rotate the craft towards the normal vector of the surface the ray hit.

 private Quaternion rotCur;
 Ray ray = new Ray(transform.position + Vector3.up * 1.0f, -Vector3.up);
     RaycastHit hit;
 void Update() {
 if(Physics.Raycast(ray, out hit) == true) {
 
     rotCur = Quaternion.FromToRotation(transform.up, hit.normal) * transform.rotation;
 
 }
 
 transform.rotation = Quaternion.Lerp(transform.rotation, rotCur, Time.deltaTime * 5);
 }
Comment
Add comment · Show 4 · 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 George_1999 · Mar 25, 2015 at 10:14 AM 0
Share

Thanks for the reply , That would work on kinematic - non rigidbody objects but since my configuration uses a rigidbody adjusting it's transform component directly would be a really bad idea ( major glitches and instability ) . so not an option for my case

avatar image Cherno · Mar 25, 2015 at 10:46 AM 0
Share

Well, you could still make it rotate towards the ground normal by using AddTorque, I guess.

avatar image AlwaysSunny · Mar 25, 2015 at 12:29 PM 0
Share

I'd bet dollars to donuts that vehicle in wipeout does not use rigidbody physics in the way you're trying to. The reason you can't make this craft stable with rigidbodies is, you are literally trying to engineer a physically accurate hovercraft dynamics simulation. That's a job for the R&D $$anonymous$$m at Lockheed $$anonymous$$artin. I have trouble counter-balancing my ceiling fan.

If your heart is set on rigidbodies, consider this: Find the ideal position and orientation using the methods described here, and use that data to directly set the transform values of a dummyTarget object. Have your rigidbody use "real" physics to attempt to come to rest in the same pos/rot as the dummy.

I won't say it's impossible to achieve a relatively stable pure physics implementation your way in Unity, but I'm not the least bit surprised to hear it's a pain in the butt to get right.

avatar image George_1999 · Mar 25, 2015 at 01:21 PM 0
Share

I don't want to necessarily use rigidbody physics to archieve that . i just want it to look almost like in the video or some pointers / tips on how the guy in the video might have done it that's all

avatar image
0

Answer by AlwaysSunny · Mar 24, 2015 at 06:10 PM

Based on how that vehicle behaves, I'd hazard to guess they are not using "pure" physics to drive its behavior. It's more likely a carefully tailored simulation specifically designed to achieve these effects.

That's not to say you can't re-create the behavior with Unity's physics sim, but you should not expect the task to be simple.

I observe two distinctive behaviors in that video: self-righting, and hovering-suspension. These should be treated as separate-but-equal behaviors.

I've never done this, but my first thought WRT using Unity rigidbodies to duplicate the effect is:

Have several feelers (raycasts) in the "down" direction of the craft's belly, and several "down" in world space, cast from the same points. (nose, tail, wing tips). Comparing the hit.normal of the "belly out" feelers to the "world down" should give you useful data about the terrain beneath the craft and the craft's orientation relative to a flat plane. You can use this data to scale the forces you apply "up" from each point (AddForceAtPoint). Also, the distance of the hits on both sets of feelers will help drive "upward" force to produce the lazy suspension effect.

The self-righting behavior might apply the torque necessary to suggest a "belly level with terrain below me" orientation depending on what the feelers are reporting, so that you only self-right when necessary.

I guess a third need emerges here; maintaining position. On an incline, these two behaviors alone will encourage the craft to "slide down" hills. This is a complicated desire, I'm afraid. Honestly if I could, I think I'd avoid using rigidbodies for this task altogether. These behaviors are not physically realistic in the first place.

Comment
Add comment · Show 1 · 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 George_1999 · Mar 25, 2015 at 08:38 AM 0
Share

I've actually already tried the suspension method described in your answer it still had the craft flip over and fly too high from the ground . i don't $$anonymous$$d it sliding , i just want it to stay aligned at all times while maintaining a low distance from the ground

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

first person controller prefab falls through floor 1 Answer

Destructible ground? 2 Answers

Irregular ground collision 1 Answer

Splatmap dry/healthy 1 Answer

How can I add Normal mapping to a Terrain custom shader? 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