#Player unable to push RigidBody3D?

1 messages · Page 1 of 1 (latest)

hybrid steeple
#

I have 2 cubes that are RigidBody3D instanced from the same resource. Both of them are in Collision Layer 1 and Mask 1
They can interact with each other and push each other (even when thrown) and no issues occur there.

I have player which is also a RigidBody3D and also in Layer 1 and Mask 1.
I move the player using apply_central_force but the player's body is unable to push the cubes. And I don't see any reason for that happening.

feral notch
#

Could you show your script and properties of your rigidbody

hybrid steeple
#

for cubes I'm just adding them to a group, I'm not doing anything with this group as of yet.

This is for moving player:

    # Moving
    if Input.is_action_pressed("move_forward"):
        direction.z = -1
    if Input.is_action_pressed("move_backward"):
        direction.z = 1
    if Input.is_action_pressed("move_left"):
        direction.x = -1
    if Input.is_action_pressed("move_right"):
        direction.x = 1
    
    # Capture camera rotation 
    var camera_rotation = camera.rotation_degrees.y
    
    # Rotate direction based on camera yaw 
    direction = direction.rotated(Vector3.UP, deg_to_rad(camera_rotation))
    
    # Movement
    if direction != Vector3.ZERO:
        var movement_force = (direction.normalized() * speed) * state.step * 50
        apply_central_force(Vector3(movement_force.x, 0, movement_force.z))
        
        var horizontal_velocity = Vector2(linear_velocity.x, linear_velocity.z)
        if horizontal_velocity.length() > max_speed:
            horizontal_velocity = horizontal_velocity.normalized() * max_speed
            linear_velocity.x = horizontal_velocity.x
            linear_velocity.z = horizontal_velocity.y
    else:
        # Movement damping
        linear_velocity.x *= movement_damping
        linear_velocity.z *= movement_damping```
#

^ here's my player

#

layers for player

#

This is for cube

feral notch
hybrid steeple
feral notch
hybrid steeple
hybrid steeple
feral notch
#

Try removing apply_impulse

hybrid steeple
#

I'm using force since it's smooth

feral notch
#

They are both acting on the same bodies so they might be conflicting each other. Although not sure but could be

feral notch
#

That also smooths the change

hybrid steeple
#

I tried with applying constant force to one cube, and it pushed the other, so it's something else.

feral notch
hybrid steeple
#

yes, I didn't touch the cube, stand in its way or anything. I just set the constant force in properties and watched

feral notch
hybrid steeple
#

Yep. They are the same resource, just instanced. Player is different scene obviously :P

feral notch
#

Well then I don't understand the use of this. What was the point of that? Isn't the problem that player is unable to push other cubes?

hybrid steeple
#

The problem is that while 2 cubes are same layer, same mask, they are able to interact with each other
but if the player is the same layer and same mask as the cubes, the player's body is unable to push the cubes.

#

No matter what force I apply, they don't even budge

feral notch
#

In that case try removing the apply_impulse part from the script

#

let the linear_velocity move the player

#

I am not saying that this is the solution.

#

I just want you to try, as this could be a reason

hybrid steeple
#

I tried that - I added velocity via properties and didn't press anything (I left the code as-is).
Collided with the cube but didn't move it

#

I can edit code I guess

feral notch
#

Ok

#

In that case let me think again

hybrid steeple
#

No problem, thanks for the help anyways, I have 0 idea why this is the case.

feral notch
#

Could you show your scene?

#

For the player

hybrid steeple
#

sure, one sec

#

and here's the cube

feral notch
#

Hmm

#

Try commenting out the whole part setting linear_velocity

#

Just for test

#

Let the apply_impulse move the body alone

hybrid steeple
#

For the player?

#

So as it was originally?

feral notch
#

I want you to comment those out

#

Don't let linear velocity interfere

hybrid steeple
#

ah yeah, okay one sec

feral notch
hybrid steeple
#

nope, same thing

#

The thing is, it's not mass of the cubes as well - they just behave as if they were static

feral notch
#

Thats the weird part

#

Hmmm

#

Hey

#

Try calling super on _integrate_force

hybrid steeple
#

super?

feral notch
#

Just for test

feral notch
#

super()

#

Its just a guess

#

I'll have to dig in it as well

hybrid steeple
#

I never used super, do I call it before func declaration?

feral notch
#

Super just called the same function of its parent

#

So like if _integrate_force has any functionality that you override. It will call that

hybrid steeple
#

Line 52:Cannot call the parent class' virtual function "_integrate_forces()" because it hasn't been defined.

feral notch
#

A wasted effort😅

feral notch
hybrid steeple
#

on the player material - yeah, but I'll try on the cube

feral notch
hybrid steeple
#

well I bounce off the cube but the cube won't move

feral notch
#

Let me go AI

#

Wait

hybrid steeple
#

I tried that haha, but good luck

feral notch
sleek flume
#

So my first thought is, strip the player to a regular rigidbody then drop it on a box and see if it moves

feral notch
#

That'll narrow out the reasons

feral notch
#

We said the same thing

#

😅

hybrid steeple
#

Aight one sec, I'll detach the script

#

Uhh one sec I gotta figure out the camera part x)

sleek flume
#

(My second thought is, are the boxes sleeping, but if bumping one into the other works then thats probably not it. Still worth turning sleeping off on them just to check)

hybrid steeple
#

nope not sleeping, one sec

sleek flume
#

(Third thought is, maybe the force is just too small to budge 'em, so make the player move at super speed)

feral notch
hybrid steeple
#

the thing is, even a tiny bump cube to cube makes them move. Not super crazy but you can clearly see

#

even if I throw

sleek flume
#

Could be it can overcome its own friction but not that + the boxes. But unlikely, yeah

feral notch
hybrid steeple
#

yep one sec, placing another camera

#

nope, nothing, the cube doesn't even move a tiny bit

#

Now this is super weird.

#

I'll make player super heavy and drop it from far above, one sec

#

okay well, 5000 KG was enough to push cube into the ground.
huh is it really the weight issue....

#

I'll attach the player script and try with the same mass

#

ye, it's mass....

#

But then again, what the hell is the rule here, why does player needs to weight 5000 kg and have a push force of a Hulk to push a 1kg cube?

#

oh for #@%# sake

#

this is my cube script...

#

Sorry guys, I am apparently blind :)