Godot Version
<stable4.2>
Question
<im trying to make ammo shell bounce. It sometimes successfully bounce, but sometimes it wont bounce. do you have any idea why? also, how can i make it bounce longer with small bounce force??
extends CharacterBody2D
var speed = 40
var gravity: float = 600.0
var bounce_damping := 0.9
var bounce_damping_partial := 0.6
func _ready():
set_as_top_level(true)
velocity.y -= 300
await get_tree().create_timer(5.0).timeout
delete_object()
func _physics_process(delta):
velocity.x *= 0.99
velocity.y += gravity * delta
if not is_on_floor():
$AnimationPlayer.play("rotate")
else:
$AnimationPlayer.play("idle")
move_and_slide()
var collision = move_and_collide(velocity * delta)
if collision:
velocity = velocity.bounce(collision.get_normal())
velocity *= bounce_damping
#velocity *= bounce_damping_partial