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 /
avatar image
1
Question by cregox · Jan 29, 2010 at 09:43 PM · 2dphysicsitweenpath

Path Controlled Character and Working With Physics on iTween

edited:

I'm completely re-wording the same question. Below, there's the original question.

Now the title is pretty self explanatory and it's basically pointed towards iTween and Bob Berkebile:

Can we mix both Path Controlled Character and Working With Physics at same time?

The result should be something similar to what I did in my portfolio (in case the first link ever breaks, this second should have one updated) but except not using any hacks like I did and once it's applied to the character (like it is) it would be applied to every other rigidbody (yes, Lerpz is a rigidbody there).

original:

physics objects in a curved 2d plane

Imagine a 2D platform game, with objects interacting physically. You would usually constrain it, making every transform.z = 0, just like the 2D Platform Demo.

Now imagine that 2D plane distorted, like a paper. There's no fixed axis and rigidbody objects are still stuck in one line, but it's curved rather than straight. Their rotation should follow that curve. It's just a twist on the platform, in the Z axis.

What would be the best way to do this in Unity? Could I build a path for them to follow? How? I still couldn't figure any way! And I believe this might be a simple answer.

( tags I couldn't create: physics curved plane path line )

edit: here are some pictures from the forums.

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 cregox · Oct 30, 2010 at 06:05 PM 0
Share

Here's something that illustrates almost exactly what I needed back then, except picture it with physics for both player and objects. - Too bad I still couldn't find time to give it a shot: http://www.pixelplacement.com/itween/examples.php look for Path-constrained Characters.

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by Horsman · Jan 30, 2010 at 01:23 AM

I misinterpreted your question the first time. I think you want the following:

The XY plane is now a curved surface, not on the groud, but the plane itself. You want objects to follow this curve.

There are two good ways of doing this: take the curve data from a model, or take the data from a spline.

If you are using a mesh, just create a single triangle strip in the shape of the curve, with the faces pointing towards the camera. Use the normal of the triangles in the strip to set the objects positions. Of course, the curve will need to have high resolutions or teh curve will look jagged as the characters move forward. You could interpolate the normals to get a smoother appearance of movement.

if you use a spline, you'll need to know a little about splines first.

http://www.unifycommunity.com/wiki/index.php?title=Interpolate

is a good way to generate some catmull rom splines. From there, use the forward direction of any point you generate on the spline as the new forward direction of your character. You might want to squash the up vector of each of those points first.

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 cregox · Jan 31, 2010 at 03:59 PM 0
Share

Yes, that is precisely the two ideas I've been trying. I actually started with a mix of both: http://www.unifycommunity.com/wiki/index.php?title=Spline_Controller

But I was hoping for some completely different approach.

Because the problem here is how to not affect the physics. On a 2D plane just setting the Z axis to zero works fine, but on this curved I'm still trying to figure it out.

I just know it will need to both get the point direction AND adjust the position. To do so, I need to know how find out which "any" point to use. That's when I got stuck.

avatar image Horsman · Feb 01, 2010 at 12:52 AM 0
Share

Ins$$anonymous$$d of parameterizing the object's position based on x and y coordinates, use the y coordinate and the ud coordiante.

The ud coord is the distance in units travelled on the spline in the forward direction. To do this, the spline you have must be parameterized by distance since most splines do not trace equal distance for equal spline parameter. Search for arc-length parameterization for 3-d curves to get the jist of it.

avatar image Horsman · Feb 01, 2010 at 12:52 AM 0
Share

A functional way to build a arc-length parameterization is by integrating the distance along the curves in small chunks and them perfor$$anonymous$$g a lookup and using a bit of interpolation to make it smooth.

avatar image cregox · Mar 09, 2010 at 08:05 PM 0
Share

I couldn't manage to use those Interpolation functions to solve this, and I'm no maths graduate to go too deep into that stuff... I don't want the curves or edges to have more weight (of dots) than the lines. They should be all equally distributed and the curves should be just a little bit smooth - so it won't disrupt the physics and it will look like it's linear. It's just a visual effect of deepness. Right now I'm trying to adapt the spline-controller to do 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

Implement 2D movement in a 3D environment while retaining physics 2 Answers

iTween Path 2D rotation, orientToPath issue. 1 Answer

Using Itween with Unity 2D, sprite flips over while using orienttopath 1 Answer

[SCREENSHOTS] itween Path, orientToPath and gameObject rotation, 2D game 3 Answers

HOW DO I USE RAYCASTHIT 2D???? 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