• Home
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (Darkly)
  • No Skin
Collapse
Godot Community

Godot Community

Stuck my character when using one way collision

Scheduled Pinned Locked Moved Ask
3 Posts 2 Posters 94 Views
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • RacoonClubundefined Offline
    RacoonClubundefined Offline
    RacoonClub
    wrote on last edited by
    #1

    hi,

    I'm using the one-way collision feature of CollisionShape2D in Godot to create a jump mechanic for my character. However, I've encountered an issue where the character gets stuck in the platform when jumping. Interestingly, when I adjust the margin value to 100, the character doesn't get stuck, but instead moves very unnaturally, almost teleporting. I'm uncertain about the cause of this behavior.

    • I'm using Godot version 3.52 mono, mac m1 pro, Ventura 13.3.
    • The character is a KinematicBody2D and the platform is a StaticBody2D.
    • Through various tests, I found that if the character jumps slightly grazing the edge of the platform, the movement seems smooth and natural.

    Does anyone have ideas or suggestions on how to resolve this?

    3.png

    1 Reply Last reply
    1
  • altriaundefined Offline
    altriaundefined Offline
    altria _init()
    wrote on last edited by altria
    #2

    Here's what come on top of my mind, I'm using Godot 4 so there might be discrepancy.

    • Collision margin of 100 is definitely too huge, that's 100 pixel! Try reducing the margin to a lower value like 5-10.

    • Check the size of your CollisionShape2D. Make sure it matches the size of the Sprite exactly. Any mismatch can cause collisions to behave unexpectedly.

    • Try enabling the "Disable Collision" option when the character jumps. You can enable it again when the jump is completed. This ensures the character does not collide with platforms during the jump.

    • Enable the "Visible Collision Shapes". This will allow you to visualize the collision shape in the editor, making it easier to debug.
      image.png

    • Instead of a CollisionShape2D, consider using a CollisionPolygon2D with a smaller number of points that more closely matches the shape of your Sprite. This can provide more accurate collisions.

    • If the jumping issue only occurs when grazing the edge of the platform, try modifying the one-way collision margin just for that edge. You can do this by creating a separate CollisionShape2D just for that edge.

    • you can combine multiple CollisionShape2Ds to get one-way collisions from multiple directions. For example, have one shape for bottom collisions and another for side collisions.

    RacoonClubundefined 1 Reply Last reply
    0
  • RacoonClubundefined Offline
    RacoonClubundefined Offline
    RacoonClub
    replied to altria on last edited by
    #3

    @altria "Thank you for all the great ideas, especially the Visible Collision Shapes which I can immediately implement. When I watch other YouTube videos, it seems like they simply click the onewayCollision button and it works flawlessly. I'm not sure what's wrong with mine and it's quite puzzling."

    1 Reply Last reply
    0

© 2023 Godot Community
Privacy - Terms - Contact

  • Login

  • Don't have an account? Register

Powered by Godot Community
  • First post
    Last post
0
  • Home
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Login

  • Don't have an account? Register