-
-
Notifications
You must be signed in to change notification settings - Fork 97
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add infinte inertia property to characterbody3D in godot4 #4805
Comments
Infinite inertia was removed by design. You don't need it anymore after configuring collision layers accordingly: godotengine/godot#31981 (comment) |
reading the comments i got it working , tnx! |
I can't figure out how to get it working correctly... For instance if I push a box into a wall it teleports and warps all over the place? Is there a way to avoid this without infinite inertia? |
Hey @hellotherekyle You can do as the comment said (Or this video) to have unidirectional collision, meaning that, if you want to push a node, but this node does not collide with the player. This can cause some weird behavior depending on what you are doing (like clipping over walls if you keep pushing the nodes against it). Now if you want you player to move for example a box, and when the box hits a wall, the box does not move anymore (nor the player) you need to do it by code. This can also be translated to 3d by just replacing the Rigidbody2d with a Rigidbody3D, here is a sample code that does exactly that: extends CharacterBody3D
@export var pushForce = 500
var move_direction = Vector3()
func _process(delta):
move_direction = Vector3()
if Input.is_action_pressed("move_left"):
move_direction -= transform.basis.x
if Input.is_action_pressed("move_right"):
move_direction += transform.basis.x
if Input.is_action_pressed("move_forward"):
move_direction -= transform.basis.z
if Input.is_action_pressed("move_backwards"):
move_direction += transform.basis.z
func _physics_process(delta):
velocity = move_direction * 15
if move_and_slide():
for i in get_slide_collision_count():
var col = get_slide_collision(i)
if col.get_collider() is RigidBody3D:
print(col.get_collider())
col.get_collider().apply_force(col.get_normal() * -pushForce) |
Describe the project you are working on
fps
Describe the problem or limitation you are having in your project
in godot 3 there was an infinite inertia property for characterbodies so they would automaticly interact with rigidbodies.
in godot4 this was removed. now a characterbody3D doesnt automaticly interact with rigidbodies.
Describe the feature / enhancement and how it helps to overcome the problem or limitation
add an option to enable infinite inertia to characterbody3D.
doesnt need to be standard, just an option
Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
eg a ui button to enable it or a line of code in move_and_slide(infinite inertia , bool , true)
If this enhancement will not be used often, can it be worked around with a few lines of script?
dont know
Is there a reason why this should be core and not an add-on in the asset library?
this will make it easier for my character setup
The text was updated successfully, but these errors were encountered: