this post was submitted on 21 Sep 2023
37 points (100.0% liked)

Godot

5888 readers
54 users here now

Welcome to the programming.dev Godot community!

This is a place where you can discuss about anything relating to the Godot game engine. Feel free to ask questions, post tutorials, show off your godot game, etc.

Make sure to follow the Godot CoC while chatting

We have a matrix room that can be used for chatting with other members of the community here

Links

Other Communities

Rules

We have a four strike system in this community where you get warned the first time you break a rule, then given a week ban, then given a year ban, then a permanent ban. Certain actions may bypass this and go straight to permanent ban if severe enough and done with malicious intent

Wormhole

!roguelikedev@programming.dev

Credits

founded 1 year ago
MODERATORS
 

I have a wall in my 3D game which is relatively thin and it can be hit on both sides with objects that may occasionally be moving somewhat fast. Is there a reliable way to ensure that the colliding objects will be stopped on either side of the wall as opposed to simply passing through?

top 4 comments
sorted by: hot top controversial new old
[–] Xenny@lemmy.world 12 points 1 year ago* (last edited 1 year ago) (3 children)

This one is easy

You just record the position of the object from the last physics tick and raycast from that location towards the objects velocity direction and if the raycast hits a wall you just move the object back to the walls position.

You usually want to add an additional check like this to all fast moving objects.

[–] Rodeo@lemmy.ca 6 points 1 year ago

There is a builtin option in Rigidbody and I think also KinematicBody called continuous collision detection or CCD. It is supposed to do this for you, and with engine code (so much faster because it's pure C++).

However I have read some posts here and there saying it doesn't work properly.

[–] MossBear@lemmy.world 5 points 1 year ago

This is a big help and makes a lot of sense! Thanks! :D

[–] Zoboomafoo@lemmy.world 3 points 1 year ago* (last edited 1 year ago)

If you don't do it like that, players will backwards long jump into a parallel universe