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

Godot

5925 readers
146 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

[email protected]

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?

you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 13 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.

[–] [email protected] 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.

[–] [email protected] 5 points 1 year ago

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

[–] [email protected] 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