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 Jesse Busch · Aug 12, 2010 at 04:12 AM · collidermeshmovingsurfacesliding

Moving a point along a plane, mesh, or collider

If anyone has experience in this matter, your input would be greatly appreciated. I'm investigating different ways of implementing a system for a game, and I need some information on this option.

In Unity, is there an easy way to a fix a point, such as an Empty GameObject, to a surface such as a plane, a mesh, or a collision shape, and move it along that given surface.

If I remember correctly, the terrain system does something like this when its interacting with a character collider. I may be wrong, but I really just don't know where to start investigating this matter.

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
0

Answer by Wolfram · Aug 12, 2010 at 10:13 AM

Generally, you'd implement some form of terrain following. Using the position of your empty GO as origin, cast a ray straight down to find the intersection with (and therefore the distance to) your terrain. If you don't hit the terrain, you are below it, so cast another ray straight up.

Then you can modify the position/speed of the empty GO as you like. For example, just clamp it to the hit.point.

The other approach would be to let the physics engine do all the work: make sure you have colliders (and probably rigidbodies) attached to all your relevant objects, and use forces to move your object around. If you end up above your terrain, gravity will make you fall back to the surface. If your force is directed downwards at an angle, the physics engine will prevent it to penetrate the terrain.

Note that if you change the position of your GO directly, without the use of forces, you'd need to combine both approaches.

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 jc_lvngstn · Aug 12, 2010 at 08:13 PM 0
Share

Can you give more details on what you're trying to accomplish? Like...do you want the object to actually be able to 'walk' or stick to the surface? If your point is on a sphere, it will need to continually 'stick' to the surface of the sphere as it 'walks' around it?

It almost sounds like you need to be able to get the normal of the face you are on, and constrain movement along that face plane. When you move to another face, your movement would be constrained to that face/plane. How you would get the "face" you are moving to, though...can Unity even provide that?

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

Raycast/Non-Physics Collider Discrepancy 0 Answers

How can I get mesh to mesh intersection? 0 Answers

Mesh collider inside cube - inverted direction 2 Answers

How to make a trigger when a Collider hits a different collider 3 Answers

Discontinuity on mesh collider seams 2 Answers


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