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
1
Question by Hadyn · Feb 07, 2011 at 05:19 AM · 2dmovementsurfaceconstrain

Constraining 2D movement to polygon surface

Hi guys,

I'm looking to create a 2.5D platformer in which there are certain platforms that the player "sticks" to, and can walk on all sides of. Effectively I want to use the normals of these platforms to tell the player character which way "up" is, and to constrain his movement to these platforms so that he can move left or right all the way around them without falling off.

The problem is that I'm new to unity and I have absolutely no idea where to begin in making this work.

For testing purposes, I'm using a rigid body sphere to represent the player character. If anyone can offer advice to help me get such a sphere to "stick" to a polygon surface and roll around it's edges, that would be very much appreciated!

The following diagram demonstrates what I'm trying to achieve, where the black object is the platform polygon, the blue object is the player character, and the lighter blue objects are example positions the player character can roll around to, ignoring global gravity, etc.

alt text

Any help or advice at all is welcome, no matter how small! I really just have no idea where to begin, and this seems like the kind of thing that other people must have done before.

Thanks in advance,

Hadyn

Comment
Add comment · Show 3
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 Skar_Universe · Sep 19, 2016 at 02:28 PM 0
Share

Hey just wondering if you even solved this issue .. I've been looking for the exact same thing but can't seem to figure out how to do it.

avatar image Bonfire-Boy Skar_Universe · Sep 19, 2016 at 02:45 PM 0
Share

Did you try the gravity-based solution suggested in the answer?

avatar image Skar_Universe Bonfire-Boy · Sep 19, 2016 at 03:14 PM 0
Share

Sorry but noob alert. I'm not really sure how to get the normal of the surface. I know it needs raycasting but I've never used it so might need some help with that if possible :) .. and after I do get the normal could I possibly even tilt my player according to the angle? .. I know nothing about raycasting .. will this give me an option to not freeze my Z axis? ..

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by Damyan · Feb 07, 2011 at 09:59 AM

I'd suggest that for these sections you turn off the global gravity and instead apply your own. Find the edge that the ball is meant to be stuck to and apply gravity along the normal of that edge.

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 Hadyn · Feb 07, 2011 at 01:57 PM 0
Share

I did think about using gravity to achieve the effect... but my $$anonymous$$d, for whatever reason, is reluctant to go that way. I guess I'm seeing the outer edge of the platform as a "path" made up of straight lines, and in my head I'm convinced there should be a really easy way to constrain movement to that "path".

But you've answered my question - the gravity idea is cool and should work. I may consider asking a new question regarding paths and whatnot, but for now - thanks for your advice!

avatar image Damyan · Feb 08, 2011 at 09:49 AM 0
Share

Glad to be of service - could you click on the 'tick' to mark this question as answered (if you think it is) :)

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

2 People are following this question.

avatar image avatar image

Related Questions

How to limit the directions an object can move? 2 Answers

Player rotation affecting Top Down 2D Movement 1 Answer

Character movement problem, floats away 1 Answer

Making side-scrolling movement? 0 Answers

Character doesn't jump repeatedly 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