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 vertex · Oct 18, 2010 at 01:55 PM · transformpositionslowdown

physics question my object setup failing collision

How to slow down a position transform that is being manipulated by hslider GUI input????

My problem is that I'm adjusting a 3D in game object's position transform based on a GUI slider value. It works like a charm most of the time. The object being adjusted (using its position adjusted from hslider values) is a simple box with box collider and no rigid body element. This box moves rigid bodies in the scene.

//this is used to transform the position
transform.localPosition = Vector3(positionX,positionY,limitControl.hSliderValue);

Everything is fine if I adjust the slider value slowly. If I move it quickly, it goes right through the rigid bodies it is supposed to manipulate.

Why not use torque or addforce to adjust the box? Because I need it to move within a specific range of transform coordinates. I really just need to slow down the movement of the "transform.localPosition" or find a more reliable way to detect collisions. I've tried a variety colliders on the box being transformed with hslider and elements in the scnee (rigid bodies) that is pushes. I've also tried a wide variety of editor settings for rigid bodies within the scene.

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

3 Replies

· Add your reply
  • Sort: 
avatar image
2

Answer by Cyb3rManiak · Oct 18, 2010 at 03:29 PM

You can try and use Mathf.SmoothDamp() or in case you're using Unity3D 3.x - Vector3.SmoothDamp(). This will try and move a float (or a Vector3) to a certain value with ease-in and ease-out to get a smooth movement. There's even an optional parameter that will let you set the maximum speed the value can change, so you can cap it.

And BTW - another solution to your problem is to increase the physics engine's solver iteration count in the physics settings. It might catch collisions on higher speeds as well if your computer is fast enough to handle it (Since it will make physics run more frequently - and in turn will cause "some" performance hit).

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 vertex · Oct 21, 2010 at 08:45 PM

Thank you. Mathf.SmoothDamp() Did it in the end. The movement is now smooth and collisions have time to do their business.

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 Bravini · Oct 18, 2010 at 03:26 PM

use transform.Translate / update the movement using Time.Deltatime, this way it will move incrementally and more smoothly.

Comment
Add comment · Show 1 · 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 vertex · Oct 21, 2010 at 08:44 PM 0
Share

I started with translate and it was smooth but had issues stopping at a specific point of the slider.

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

No one has followed this question yet.

Related Questions

make player move in direction it's facing 2 Answers

What is the reasoning of multiplying by Time.deltaTime 1 Answer

does not work check if dead 1 Answer

Help around an approach to a "Virtual Motion Table" in Unity 0 Answers

Camera movement 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