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 Angel · Jan 25, 2011 at 09:35 PM · physicsrigidbodyitweencollision-detection

How do I get the 2.5d platformer's rigidbody physics to follow a path?

Hi,

I'm using itween's PutOnPath function to place the character on a path but I'm not sure how I can get collision detection working for the character and restrict physics to a path. Is that possible?

Example of problem:

http://www.atomk.com/twofived/twofived.html (boxes have rigidbodies attached, but only travel on the X axis)

Should I just raycast from the character to detect collisions instead? I am not sure what's an adequate approach to this problem.

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

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by pixelplacement · Jan 31, 2011 at 12:46 AM

I'd recommend the raycast route on this one. I really like the way this works - it's inspiring to see your work evolve and I appreciate you sharing this. If you can't figure out a suitable solution to this let me know and maybe I'll take another look.

Comment
Add comment · Show 2 · 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 Angel · Feb 02, 2011 at 07:53 PM 0
Share

Thank you so much! Your comments mean a lot to me. I appreciate it :) Yeah, I will go with the raycasting approach for the character collision detection.

For restricting the physics to the path, I tried locking the Z of the objects to the path, but I am stuck trying to figure out how to calculate the percentage that the object is on the path. Do the percentages match if I just choose the point that is closest to the object and try to figure out the percentage from that?

avatar image pixelplacement · Feb 04, 2011 at 05:09 PM 0
Share

Not sure I understand you 100%...

avatar image
0

Answer by Aurelio Provedo · Apr 07, 2011 at 10:01 AM

Hello there

Did you find a solution for this? It looks like I'm making just the same type of game you are, and stumbled upon this question.

I have also thought about finding out the closest point on the spline for the point that the rigidbody is at, and then setting its pointOnPath to that amount. Then on every FixedUpdate set the body's position to that PointOnPath. I might have the ClosestPointOnPath method done by this evening.

I also considered overriding OnCollisionEnter. But with only the contacts list and the relativeVelocity information, it would be too difficult for me to implement a collision constraint to the path.

So, any progress? Anything you can share?

Comment
Add comment · Show 4 · 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 Angel · Apr 08, 2011 at 06:06 AM 0
Share

Ahhh wow. I have never found a solid solution for this, so I just worked around it. I thought about it and if I took this route, the physics would still look "jerky" because of it trying to correct itself. If you found a solution though then that's awesome!

avatar image Aurelio Provedo · Apr 08, 2011 at 06:58 AM 0
Share

I was doing some tests yesterday. In FixedUpdate, I do the following: Get the body's velocity magnitude on the XZ plane - movement in Y axis is not affected by the path in my game. Get the world position of the point on the path at the body's position + the XZ velocity magnitude. * $$anonymous$$ake the body's velocity point towards that world position.

This seems to work better than expected. I didn't have time to make many tests, though, particularly not collisions.

avatar image Angel · Apr 23, 2011 at 11:58 PM 0
Share

Did everything go well?

avatar image iloveaphextwin · Mar 26, 2012 at 08:35 AM 0
Share

Is there any way you could show me your code for this. I have been trying to do exactly the same thing for the last few days and only realised I could use the iTween method today. I would really appreciate any help and will do all I can to help in return.

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

Strange physics, rigidbody, iTween activity 1 Answer

Kinematic rigidbody with interpolation issue 0 Answers

Prevent rigidbody being affected by character controller 2 Answers

Prevent player from "Running Over Top Of" specific colliders. 0 Answers

Rigidbodies won't collide if mass difference is too high 0 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