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 Hondune · Oct 20, 2010 at 03:33 AM · controljointconfigurablejoint

controlling the target rotation of a configurable joint via input?

so basically im trying to control the target rotation of a configurable joint using keyboard input between a minimum and maximum value.

id like to make it so that the longer you hold down the button the more the target rotation goes up to a certain value. so it starts at 0, and as you hold down the button it raises that value up till the max value (lets use 10 for this example), and if you let go of the button at say, 6, it will stay at 6 untill any further input. and if the value gets to 10, you can no longer rotate in this direction. then i also want to be able to do the vice versa to bring that value down the same way it went up. so in the end to put it in more simple terms, you can control the joint to any value between 0 and 10

the problem is i am having some major trouble trying to figure out how to do this. i imagin id start with some values like val MaxtargetRotation = 10 MintargetRotation = 0 or something along those lines. but im just not sure where to go from there.

im using java scripts btw.

alernativly if its easier, i also would mind it to just simply change the value to 10 when the buttons pressed and go back to the center (5 in this case, which i would set in the inspector) when the buttons not pressed. that might work to, i think. but it would be nice to know how to do both for future reference :) thanks for your time to anyone that helps me out! its very appreciated.

i have searched, BTW, but havnt found anything that works for this (or works at all really, but im probably missing something. im quite new to this)

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

· Add your reply
  • Sort: 
avatar image
1

Answer by Hondune · Dec 02, 2010 at 04:50 AM

ended up working like this, if anyone else if having this issue. and i must say, it works really really well and makes for some great natural feeling movement

var KneeJoints : ConfigurableJoint; var HipJoints : ConfigurableJoint; var ChestJoint : ConfigurableJoint; var ElbowJoints : ConfigurableJoint; var ShoulderJoints : ConfigurableJoint; var ElbowValues : Vector3; var ShoulderValues : Vector3; var KneeValues : Vector3; var HipValues : Vector3; var ChestValues : Vector3;

function FixedUpdate () { if (Input.GetKey("right")) { KneeJoints.targetRotation = Quaternion.AngleAxis(KneeValues.x, Vector3.right); HipJoints.targetRotation = Quaternion.AngleAxis(HipValues.x, Vector3.right); ChestJoint.targetRotation = Quaternion.AngleAxis(ChestValues.x, Vector3.right); ElbowJoints.targetRotation = Quaternion.AngleAxis(ElbowValues.x, Vector3.right); ShoulderJoints.targetRotation = Quaternion.AngleAxis(ShoulderValues.x, Vector3.right); } else if (Input.GetKey("left")) { KneeJoints.targetRotation = Quaternion.AngleAxis(KneeValues.y, Vector3.right); HipJoints.targetRotation = Quaternion.AngleAxis(HipValues.y, Vector3.right); ChestJoint.targetRotation = Quaternion.AngleAxis(ChestValues.y, Vector3.right); ElbowJoints.targetRotation = Quaternion.AngleAxis(ElbowValues.y, Vector3.right); ShoulderJoints.targetRotation = Quaternion.AngleAxis(ShoulderValues.y, Vector3.right); } else { KneeJoints.targetRotation = Quaternion.AngleAxis(KneeValues.z, Vector3.right); HipJoints.targetRotation = Quaternion.AngleAxis(HipValues.z, Vector3.right); ChestJoint.targetRotation = Quaternion.AngleAxis(ChestValues.z, Vector3.right); ElbowJoints.targetRotation = Quaternion.AngleAxis(ElbowValues.z, Vector3.right); ShoulderJoints.targetRotation = Quaternion.AngleAxis(ShoulderValues.z, Vector3.right); } }

(code sample thing isnt working?)

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

1 Person is following this question.

avatar image

Related Questions

How to make camera position relative to a specific target. 1 Answer

Joints Configured from Script do not work properly? $20 reward 3 Answers

Joint system scale problems 2 Answers

OnJointBreak 1 Answer

How to gradually increase targetAngularVelocity value of a Configurable joint? 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