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 Haxina · Nov 10, 2013 at 04:45 PM · c#mousewheelcolliderlocksteering

Locking rotation of WheelCollider

Hello! I'm not sure if this has been asked before or not, but i couldn't find anything. What i'm trying to do is using the Mouse to rotate WheelCollider, but when i do that it just rotates back again.

Currently i'm using this code:

 public WheelCollider FrontLeftWheelCollider;
 public WheelCollider FrontRightWheelCollider;
 
 public float MouseSteering = 10.0f;
 void Update()
 {
     FrontLeftWheelCollider.steerAngle = MouseSteering * Input.GetAxis("Mouse X");
     FrontRightWheelCollider.steerAngle = MouseSteering * Input.GetAxis("Mouse X");
 }

Any ideas on how to make it rotate the WheelCollider with the Mouse X axis, and keep it locked at that rotation?

Or do i need to write a completely new script for that?

Comment
Add comment · Show 4
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 Starwalker · Nov 21, 2013 at 06:51 PM 0
Share
 void Update()
 {   if(Input.Get$$anonymous$$ouseButton(0))
     {

     FrontLeftWheelCollider.steerAngle = $$anonymous$$ouseSteering * Input.GetAxis("$$anonymous$$ouse X");
     FrontRightWheelCollider.steerAngle = $$anonymous$$ouseSteering * Input.GetAxis("$$anonymous$$ouse X");

     }


 }

It will only work if left mouse button is pressed.

avatar image Haxina · Nov 21, 2013 at 07:17 PM 0
Share

Thanks for the reply, unfortunately it didn't lock the rotation of the WheelCollider, ins$$anonymous$$d it only made it possible to rotate when Left $$anonymous$$ouse button is hold down. Am i not clear enought? Do i need to specify my question better? Thanks for helping though :)

avatar image Starwalker · Nov 21, 2013 at 08:03 PM 0
Share

Actually, the only way to lock it is that you dont update the Input, meaning you will have to restrict the input, since you have put the above code in an Update function, it will run regardless, so in order to lock it, you need another event which controls the input. What I suggested is just another event.

You are polling new input every frame + updating the angle, if you want to lock the angle, you either have to stop the "update" on either the angle or the Input, if both are always updating every frame, you cant actually have a "lock" mechanism.

avatar image Haxina · Nov 24, 2013 at 09:31 AM 0
Share

Sorry for the very late reply! Well that sounds quit logic, unfortunately i'm not good enought at program$$anonymous$$g so i'm going to learn more before getting into Unity3D again.. So all that with events, i'm not really sure about how to do it, but i get the point! Thanks for taking your time and helping :)

0 Replies

· Add your reply
  • Sort: 

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

17 People are following this question.

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

Related Questions

Distribute terrain in zones 3 Answers

Steering Wheel with mouse drag 0 Answers

Multiple Cars not working 1 Answer

Angry Birds Style Loader (Load the Birds to be fired) 0 Answers

Check if mouse cursor is locked 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