Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 11 Next capture
2021 2022 2023
1 capture
11 Jun 22 - 11 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 Warpeon · Jul 22, 2015 at 03:39 AM · 2d gameplayergravityspeedplatform

Disable/Change gravity effects on inclined platforms

Hello,

How can I disable or change gravity effects on inclined platforms to make these things happen in my 2D platformer game :

  1. When the object is stopped on a inclined platfrom, it will stay stopped (I disabled the rotation).

  2. When the player walks in a ramp or something similar, it will keep the same speed and will not leave the platform's surface.

Comment
Add comment · Show 2
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 KdRWaylander · Jul 22, 2015 at 07:39 AM 0
Share

I'd say don't use Unity's gravity, make your own one :)

avatar image Warpeon · Jul 22, 2015 at 01:17 PM 0
Share

It's the same thing. There is a force pushing the object down and when it's on an inclined plaftorm it keeps descending.

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Mulldor · Jul 22, 2015 at 01:45 PM

What you are looking for is the "Physics.gravity" variable.

So, lets say you want jump up to a platform above your head. When you are a certain distance away. You change the Physics.gravity.

See: http://docs.unity3d.com/ScriptReference/Physics-gravity.html for more information on gravity.

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 alexi123454 · Jul 22, 2015 at 01:55 PM 0
Share

Physics.gravity changes the gravity for every object in the whole scene, not just the player on the ramp. That might not provide the intended effect :P

avatar image
0

Answer by alexi123454 · Jul 22, 2015 at 01:54 PM

I assume you're using a Rigidbody2D for your character. In that case, one of the variables is "gravityScale". Setting that to 0 causes the rigidbody to ignore gravity, allowing it to not slide down the platform.

If you import the default asset "Characters" and have a look at the scripts on the First Person Controller, it has a method built-in to keep the player stuck to surfaces. It may be worth having a look at.

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

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

how i can make my player lose 1 live after HP = 0 ? 0 Answers

How Can I Make A Platform Lauch My PLayer Into The Air? 2 Answers

Make box tip over edge of platform 1 Answer

Player parent to platform problem 0 Answers

How to make a 2D spritesheet 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