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 LS16BMX · Nov 30, 2011 at 10:43 AM · hingejointhinge jointhingemotormotorbike

How to effectively control hinge joint motors (scene file included) ?

I have a simple bike scene - http://wtrns.fr/rUVFrHnc2AqRLZ The wheel is powered by the hinge joint motor. How can I develop a simple control script to allow proper acceleration via a key press ? Any help would be most appreciated.

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 LS16BMX · Nov 30, 2011 at 03:38 PM 0
Share

bump......

4 Replies

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

Answer by vlePa · Mar 08, 2012 at 12:15 AM

Try this:

 // up and down keys, range [-1, 1]
 acceleration = Input.GetAxis("Vertical");
 
 // key up is powah * 1, key down is powah * -1, no key is powah * 0
 hingeJoint.motor.force = powah * acceleration;

Hope this helps.

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
1

Answer by I9ball · Oct 14, 2012 at 07:16 AM

Have you considered AddTorque?

It may work well, especially if you want wheel to react to pedal pressure like the real deal.... Maybe each key press adds torque to the wheel which would simulate foot (leg) pressure on the alternating pedals.... I don't know, just throwin it out there.

P-

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 LS16BMX · Oct 14, 2012 at 03:32 PM 0
Share

thanks dude I've tried many variations including addTorque, ran into plenty of other bigger issues for now lol

avatar image I9ball · Oct 16, 2012 at 07:29 AM 0
Share

$$anonymous$$k... Good luck, and take care.

avatar image
0

Answer by LS16BMX · Dec 02, 2011 at 12:36 PM

This is what i've got at the moment, can anybody suggest a good way to link the powah variable to a key input ?

var powah : int = 0;

function FixedUpdate () {

hingeJoint.motor.targetVelocity = 1080;

 hingeJoint.motor.force = powah;
 

}

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 Cinebeast · May 15, 2013 at 06:08 AM

when i try to use this code "ConfigurableJoint.angularXDrive.maximumForce = powah;"

there's always an error that says something like this

Assets/tehscript.cs(20,35): error CS0120: An object reference is required to access non-static member `UnityEngine.ConfigurableJoint.angularXDrive'

and that kinda sucks because "ConfigurableJoint.angularXDrive.maximumForce" is pretty much the same as "hingeJoint.motor.force" and apparently "hingeJoint.motor.force = powah" works fine on its own? without any other code...

C# FYI

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

HingeJoint Motor's values not being changed by script (show in debug, but not inspector) 1 Answer

How can i change HingeJoint's axis from code? 0 Answers

Hinge Motor Stuck After Hitting Limits 1 Answer

How to make an arm with multiple, controllable joints? 2 Answers

Hinge joint connected body scripting issues 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