I'm creating a funny game where the player can shoot sheep.
I added the bullet spawn when the user click the mouse...
Everything works perfectly.
But I want that the bullets can bounce in the scene.
How can I add this function?
# Player.gd - called when we press the shoot button - sapwn a new bullet
func shoot():
var bullet = bulletScene.instance()
get_node("/root/MainScene").add_child(bullet)
bullet.global_transform = muzzle.global_transform
bullet.scale = Vector3.ONE
ammo -= 1
$SheepSound.play()
Bulet.gd
extends Area
var speed : float = 30.0
var damage: int = 1
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
#move the bullet forward
translation += global_transform.basis.z * speed * delta
func _on_Bullet_area_entered(body):
if body.has_method('take_damage'):
body.take_damage(damage)
destroy()
func destroy():
queue_free()