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 n8 · Jul 12, 2011 at 05:49 PM · collidersvehicle

vehicle stops when colliding with ramp

I have a vehicle that floats above a terrain object and will "float" over various hills/bumps/etc. I would like to create a mesh for a ramp that the vehicle can hit to get launched into the air. the vehicle is using a capsule collider and the ramp is using a mesh collider. The ship will always come to a complete stop when colliding with the ramp instead of climbing the ramp and then flying into the air.

I also tried removing the mesh collider from the ramp and instead using rotated box colliders. The same thing happens in both instances. Any ideas?

EDIT here is the most important part of the flight script that controls how high the vehicle floats above the terrain

 function FixedUpdate()
     {
     //other code for random stuff
 
 transform.position = Vector3.Lerp(transform.position, new Vector3(transform.position.x, GetHoverHeight(), transform.position.z), hoverHeightStrictness);
 
 //more code for more random stuff
     }
         function GetHoverHeight()
             {
                 if( transform.position.y > Terrain.activeTerrain.SampleHeight(rigidbody.position) + (hoverHeight + buffer)) {
                     if(boosting){
                         floatHeight -= (gravity + boostGravityMultiplier);
                     }else {
                         floatHeight -= gravity;
                     }
                     return floatHeight;
                     //~ thrust = 0;
                 }
                 else if( transform.position.y < Terrain.activeTerrain.SampleHeight(rigidbody.position) ) {
                     floatHeight = Terrain.activeTerrain.SampleHeight(rigidbody.position) + (hoverHeight);
                     return floatHeight;
                 }
                 else if( transform.position.y < Terrain.activeTerrain.SampleHeight(rigidbody.position)+ (hoverHeight - buffer)){
                     floatHeight += climbSpeed;// Terrain.activeTerrain.SampleHeight(transform.position)+ hoverHeight;
                     return floatHeight;
                     //~ thrust = 0;
                 }
                 else {
                     floatHeight = (Terrain.activeTerrain.SampleHeight(rigidbody.position) + hoverHeight + buffer);
                     return floatHeight;
                     //~ thrust = 0;
                 }
                 
                 return floatHeight;
             }
Comment
Add comment · Show 2
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 Chris D · Jul 12, 2011 at 06:07 PM 0
Share

Post your code.

avatar image n8 · Jul 12, 2011 at 08:38 PM 0
Share

the posted code only shows how i am using the "terrain.sampleHeight" to find the height of the terrain underneath my gameObject and then bump the GO up the desired float distance. Should I use raycast to detect other meshes to do the same thing?

1 Reply

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

Answer by Waz · Jul 12, 2011 at 11:17 PM

You are moving your ship by changing it's transform.position. That will defeat any physical interactions.

Whatever you do to make the ship go over ramps will work to also keep your ship floating above the terrain, and even let it "get air" off steep rises in the terrain.

For example, you can make a physical ship float just by having the collider somewhat below the ship's visual mesh.

So fix how you are floating, then you'll be able to get the ramps working.

Comment
Add comment · Show 5 · 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 n8 · Jul 13, 2011 at 01:45 AM 0
Share

Oh so what you are saying is that by setting the ship's float height explicitly, it is essentially "pulling" the ship down into the ramp. This causes the ship to just stop ins$$anonymous$$d of riding up to the ramp, correct?

Are you suggesting I have an empty game object with a collider attached to it that is offset to the float height, and then have a regular collider attached to the ship to catch crashes?

avatar image n8 · Jul 13, 2011 at 02:30 AM 0
Share

so i tried what you suggested and it did work, the ship will now ride up over any colliders. the problem now is that everything is too stiff, the ship feels like it is dragging something over the terrain (which it is). I need to figure out a way to make it feel like it is gliding over the surface.

avatar image Waz · Jul 13, 2011 at 04:03 AM 0
Share

The Physics$$anonymous$$aterial of the collider should be frictionless - so zero frictions and a Fiction Combine mode of $$anonymous$$inimum. Is that what you mean by "stiff"?

avatar image n8 · Jul 13, 2011 at 02:37 PM 0
Share

not exactly, what is happening is that i have a collider set beneath the ship to force it up into the air. That collider is dragging across the terrain and any other obstacle. Any time there is a bump in the terrain or anytime i go over an obstacle, the ship is jarred around. It is kind of like having shocks made out straight iron rods

avatar image Waz · Jul 13, 2011 at 09:07 PM 0
Share

Perhaps rather than having the visual ship as part of the RB, make it a separate object that you Lerp to the position of th RB.

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

Why vehicle decelerate on steerAngle 0 Answers

physics.OverlapSphere colliders 1 Answer

Car flipping and losing wheels on start 0 Answers

When player enters triggerzone call function 2 Answers

health depleat with colliders 2 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