How do I make it reflect or bounce only when it hits a certain obeject

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

var velo = Vector3.ZERO
var speed = 20
var gravity = 9

func _process(delta):
	velo.y -= gravity * delta
	velo = transform.basis.z * speed
	velo = move_and_slide(velo, Vector3.UP)
	if is_on_wall():

## Area
func _on_Area_body_entered(body):
	if body.is_in_group("wall"):
:bust_in_silhouette: Reply From: JeanKouss

You can set the collision layer to match only with the collision mask of that object.

You can easily find tutorials about this.

Thank you very much for your help but my aim is to “bounce or reflect” when it collision the object.
like this

func _process(delta):
	var col = move_and_collide(velocity * delta)
	if col:
		#velocity = velocity.reflect(col.normal)
		velocity = velocity.bounce(col.normal)

ramazan | 2022-09-11 19:56