Comments (4)
To resolve this I added an extra grounded check when encountering a wall:
(assuming that if we're grounded and not moving sideways then we also don't want to move vertically either)
// These mean we can't progress forward. Either a wall or a slope
if (HasFlag(CollidedSurface.LeftWall) &&
_velocity.x < 0 &&
_collidedNormals[DIRECTION_LEFT] == Vector2.right ||
HasFlag(CollidedSurface.RightWall) &&
_velocity.x > 0 &&
_collidedNormals[DIRECTION_RIGHT] == Vector2.left)
{
if (IsGrounded())
{
velocity = Vector2.zero;
}
else
{
_velocity.x = 0;
}
}
This resolved the problem for most speeds, but when travelling at fast speeds with a slow computer I found that I had to increase Environment Check Distance from 0.02f to 0.1f.
On even slower computers it may need to be increased more or there may be a more efficient solution..
from unity-2d-platformer-controller.
I see you have a fork. Can you please commit an example scene and the fix so We can take look.
from unity-2d-platformer-controller.
Is this when encountering a wall or a steep slope?
Also, given that this is in FixedUpdate then it shouldn't matter if the computer is fast or slow.
from unity-2d-platformer-controller.
I've also seen this problem and tried the fix from Mr-Sheen a few posts up. It seems to fix the issue in most cases but if the character hits a vertical wall while running up a slope at too high a speed he'll do a little jump/bounce.
All the slopes in my game are 45 degrees, with all other colliders being perfectly horizontal or vertical.
from unity-2d-platformer-controller.
Related Issues (20)
- Prevent wall stick when only partially against a wall HOT 2
- No namespace for PlatformerMotor2D and MovingPlatformMotor2D
- Tap for small jump? HOT 1
- How I can have Touch Control? HOT 1
- AI Problems!
- Disabling and enabling the motor (with a rigidbody attached to) on a ramp makes the motor move permanently
- One Way Platform bug, when wall jumping
- Bug when double tap right arrow on small slope
- PC2D gets stuck at 45 degree angle using Polygon Collider 2D HOT 2
- Sliding down slopes while also allowing movement upward HOT 2
- Thank you!
- No slip on sloped surfaces HOT 3
- Applying a force to motor, like AddForce()
- Switch collider to capsule colllider
- Where are conrtols handled? HOT 3
- Hitch in wall interaction HOT 1
- 2D Platformer Games HOT 1
- Move Up&Down When Sticking on Wall
- Permission HOT 2
- Collision and trigger
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from unity-2d-platformer-controller.