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 /
This question was closed Feb 02, 2019 at 05:34 PM by LegendaryCreator for the following reason:

Other

avatar image
0
Question by LegendaryCreator · Feb 26, 2017 at 01:20 PM · physicsblendercontrollermodelc #

How do i make my model hover

I used the script from the hover car tutorial and added it to my bender model with a rigid body everything but the hover aspect of the car works When pressing the keys it moves and rotates but does not float in the air like it should. The script works when i use it on a cube but not the blender model.

`using UnityEngine; using System.Collections;

public class HoverMotor : MonoBehaviour {

 public float speed = 90f;
 public float turnSpeed = 5f;
 public float hoverForce = 65f;
 public float hoverHeight = 3.5f;
 private float powerInput;
 private float turnInput;
 private Rigidbody carRigidbody;


 void Awake () 
 {
     carRigidbody = GetComponent <Rigidbody>();
 }

 void Update () 
 {
     powerInput = Input.GetAxis ("Vertical");
     turnInput = Input.GetAxis ("Horizontal");
 }

 void FixedUpdate()
 {
     Ray ray = new Ray (transform.position, -transform.up);
     RaycastHit hit;

     if (Physics.Raycast(ray, out hit, hoverHeight))
     {
         float proportionalHeight = (hoverHeight - hit.distance) / hoverHeight;
         Vector3 appliedHoverForce = Vector3.up * proportionalHeight * hoverForce;
         carRigidbody.AddForce(appliedHoverForce, ForceMode.Acceleration);
     }

     carRigidbody.AddRelativeForce(0f, 0f, powerInput * speed);
     carRigidbody.AddRelativeTorque(0f, turnInput * turnSpeed, 0f);

 }

} alt text

unityhovercar.png (211.8 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

  • Sort: 
avatar image
0

Answer by K-Anator · Mar 12, 2017 at 03:20 PM

Blend files have a tendency to import themselves with one axis rotated 90 degrees. So chances are your ray on line 23 that's supposed to point down (-transform.up) might not actually be pointing down. Check different directions and see if that helps. You might be able to get away with making the blender file a child of an empty.

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

Follow this Question

Answers Answers and Comments

6 People are following this question.

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

Related Questions

MMD How to export model and animations to Unity as 3rd person controller? 2 Answers

Need help with character unity+blender 1 Answer

Terrain physics is not working. Please help. 1 Answer

Every time my character hits or touches the walls he gets stuck or acts as if the object the character hit was a magnet. 0 Answers

Get a free moving ball. 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