Coder Social home page Coder Social logo

2dplatformer-tutorial's People

Contributors

seblague avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

2dplatformer-tutorial's Issues

Fixed: Jittery movement at angle platform peaks

Hi guys,
There was an issue I had where going over the edge of a peak on an angle platform causes you to jitter as it figures out where the collision occurs. As one ray goes over the edge the player drops until a suitable collision occurs as shown in this image
jitterypeak

I set out to solve this without increasing the number of rays cast down and decided on a compromise that isn't exactly elegant but it largely solves the problem.

My idea was that it only occurs in a small area so I could cast a ray horizontally across the bottom of the player then use the collision from that to cast one more ray downwards to create collisions. This adds two more ray calculations and makes far smoother situations in this case.

jitterypeakfixed

The following code was added to the Controller2D.cs script, at the top of the VerticalCollisions method.
Note that I also took the creation of rayOrigin and hit out of the for loop.

`
Vector2 rayOrigin = raycastOrigins.bottomLeft + new Vector2(skinWidth, -skinWidth);
float horRayLength = Vector2.Distance(raycastOrigins.bottomRight, raycastOrigins.bottomLeft) - (skinWidth * 2);
RaycastHit2D hit = Physics2D.Raycast(rayOrigin, Vector2.right, horRayLength, collisionMask);

    if (directionY == -1)
    {
        if (hit && hit.collider.tag != "Through")
        {

            Debug.DrawRay(raycastOrigins.bottomLeft, new Vector2(horRayLength, 0), Color.green);
            rayOrigin = new Vector2(hit.point.x, raycastOrigins.bottomLeft.y);
            hit = Physics2D.Raycast(rayOrigin, Vector2.down, rayLength, collisionMask);
            Debug.DrawRay(rayOrigin, Vector2.down, Color.green);

            if (hit)
            {
                moveAmount.y = (hit.distance - skinWidth) * -1;
                rayLength = hit.distance;

                if (collisions.climbingSlope)
                {
                    moveAmount.x = moveAmount.y / Mathf.Tan(collisions.slopeAngle * Mathf.Deg2Rad) * Mathf.Sign(moveAmount.x);
                }

                collisions.below = true;
            }
        }
    }

`

If anybody has a cleaner solution to this or needs it explained better, let me know

PlatformerController.cs in episodes 7 onwards is broken

Unity 5.0.2f1 and 5.1.2f1 throws: "error CS1501: No overload for method Move' takes2' arguments" when directly copy and pasting PlatformerController.cs from the source files.

Worked about 2 weeks ago, possibly caused by some new Unity update?

Velocity.x never hits 0 unless you jump

Hi Sebastian,

Thank you so much for the tutorials, I have found an issue in my code which I believe is an issue in the base code but has no direct impact on the platformer functionality.

Using Mathf.SmoothDamp for velocity x with a fixed float as you do in the code seems to keep it looping between -10 and 10, it never resets to 0 unless you jump and land. I discovered this as I had implemented some code to not start climbing a wall unless a player pressed against that wall.

I have worked around the issue by using inputs for my wall climb detection, however I can't seem to figure out how to fix the smoothdamp. Setting Time.deltatime instead of the accelerationTime just results in immediate stopping. I'll submit a pull request if I ever figure it out

Problem occurs when player stops on the slope after climbing

Thank you for your brilliant tutorial, but I've found a problem after watching and practicing the episode 5, it is that if the player stop on a slope after climbing, it may slip a bit after a while, especially when the angle of the slope is really large.
image
the first picture shows the raycast of the player when it just finished climbing
image
the second picture shows the raycast of of the player after a while

I think it may caused by the gravity? Because the gravity applies on the player every frame.

So have you found this problem either? Or maybe there is something wrong with my code?I use Unity version 5, too
Thanks.

Sorry about my poor English XD.

Slope Transition Issue

First off, great tutorials!

Has anyone noticed any issues when transitioning between slopes and the collisions data? Specifically the status of collisions.below?

Using my own copy and the source code from the repo produces the same following results (watch the output of the Below box):

Scene Gif

Notice the quick switch between true/false? It's made it somewhat unreliable to use any animation states between grounded to falling. Any help is appreciated.

Still accumulating gravity

Hi there not too sure at what point I went wrong but for some reason my sprite still accumulates gravity which doesnt allow it to jump and falls off the platform really quick.

Could anyone help me on this matter?

Ledge on moving platform

Hi i will like to make the character ledge on a moving platform. I have tried but to only thing i have is on a static platform.

Moving platform transform.position goes to infinity

When the platform has to move horizontally to reach the next waypoint it goes in the opposite direction and you get this error : transform.position assign attempt for 'MovingPlatform' is not valid. Input position is { -Infinity, 6.374002, 0.000000 }.

Moving vertically is no problem . Cyclic or not also doesn't seem to matter.
I didn't have this problem after finishing the tutorial but rather a few months later when opening the project again.

Using bounds to get player position

There is an issue with using the bounds of a BoxCollider2D outside of the fixed update loop.

From the tests I have done the bounds may not always be relative to the player position in the update loop. This means the raycasts which use the bounds position may return no collision when they should be.

Horizontal player movement on ascending vertical platform causes player to move through the platform.

The issue seems to lie in VerticalCollisions in the Controller2D script.

When the player inputs Horizontal movement while on an ascending platform, the VerticalCollisions function does not seem to add the expected velocity.y. I've been able to figure out that the first "if (hit) {}" of the function only evaluates to "true" some of the time while the player is on ascending platforms. Other than that I'm unsure of what exactly is causing the problem.

Player can enter wall when landing on corner with horizontal movement

I've implemented this code from scratch without Unity, and it works great, though I'm having an issue with the collision.

If I align my player against a box and jump and slightly tap towards the box at the right time, I'm able to get past the ray casts and enter through the box.

Collision issue 1
Collision issue 2

In the recordings above, I have 4 rays on top and bottom, and 8 on either side.

Jittery Issue

When climbing a slope and running into an overhang slope that should stop the player, the player will slowly climb the overhang until it gets too far from the slope it thinks it's climbing and falls.

Here's a gif of the problem.

In the gif I'm only holding left.
The slopes are -70 and 70.
Max Slope Angle is 80

Besides those nothing is changed from the E13 project.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.