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 /
  • Help Room /
avatar image
0
Question by Floshosho · Dec 01, 2015 at 02:41 PM · hingejointcs1612

How do i change the upper angle limit and lower angle limits of a hingejoint2d object?

I get the error: Assets/AngleChanger.cs(35,36): error CS1612: Cannot modify a value type return value of `UnityEngine.HingeJoint2D.limits'. Consider storing the value in a temporary variable

I am trying to change the limits via script.. heres my code:

 public int num;
 public HingeJoint2D angleLimit;
 
 
 void Start () 
 {
     num = 90;
 }



 public void addNum2()
 {
     float num2;
     
     
     if (num > 90 || num == 90) 
     {
         Debug.Log ("You can't go higher than 90 degrees!");
     } 
     else 
     {
         num += 5;
         num2 = (90 - num) * -1;
         angleLimit.limits.max = num2;
         
     }
 }

 public void subtractNum2()
 {
     float num2; 
     
     
     if (num < 0 || num == 0) 
     {
         Debug.Log ("You can't go lower than 0 degrees!");
     } 
     else 
     {
         num -= 5;
         num2 = (90 - num) * -1;
         angleLimit.limits.max = num2;
 
         
     }
     
 }
 

}

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 Floshosho · Dec 01, 2015 at 06:21 PM 0
Share

Im trying to change the upper and lower limits for my hingejoint2d but it wont let me change it. is this the correct code for it? if not, whats the correct call and what am i doing wrong

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Floshosho · Dec 01, 2015 at 07:18 PM

I found out what i was doing wrong, problem solved :)

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Joint two carriages with hingejoint in runtime 0 Answers

Children of a hingejoint not colliding with parent's mesh when connectedBody is assigned 1 Answer

Rope (made with joints) connected to a movable transform acts weirdly 0 Answers

How do I model a piston? 0 Answers

how to test if something enters a specific trigger and set that object to a gameobject variable!?!? 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