kinematic body 3d reflect or bounce

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By ramazan

hi everybody
Like 3d pinball style game. It has to bounce off walls, but I also need gravity. Because it has to go uphill or something. I tried with RigidBody but it also bounce up in y_axis

when i add gravity to this code it also tries to jump normally on the ground

    extends KinematicBody
   / ball
    var velo = Vector3.ZERO
    func test(delta):
    	var collision = move_and_collide(velo * delta)
    	if collision:
    		var reflect = collision.remainder.bounce(collision.normal)
    		velo = velo.bounce(collision.normal)
    		move_and_collide(reflect)
    	pass
    
     func _process(delta):
              test(delta)

velocity in another scene
ball.velo = transform.basis.z * 20

I would still recommend using RigidBody, You can disable Y axis in its inspector, so it will only move in X and Z

Inces | 2022-09-03 18:19

Thank you very much Inces. But I also need the y_axis :slight_smile: . let me try a little more

ramazan | 2022-09-04 08:26

Sure, just let me remind You, You will not be able to build flipper hit ball mechanic with Kinematic Body. Kinematic body doesn’t have properties nor methods to detect and apply precise physics, like being struck by an spherical angle of a flipper

Inces | 2022-09-04 10:02

Definitely . I switched to “Rigidbody” as you said. Thank you very much again. So I got the jumping thing done with a little trick

sorry i use google translate

ramazan | 2022-09-04 11:13