I am trying to make it so that, when I shoot the enemy, it goes from completely random movement (on all axes) to random movement on a single axis (facing the player, to simulate a “strafe”).
I used print to check that it works but, no matter what I try, nothing works. (X
Thanks to those who have advice. ^^
‘‘‘func _straf():
$RayCast3D.collide_with_bodies = true
if _current_health < max_health :
$RayCast3D.collide_with_bodies()
var coll = $RayCast3D.get_collider()
if coll != null and coll.name == $“../JOUEUR”:
coll.print(“LOL”)’’’
Sorry for the delayed response, I've had some issues and haven't been coding lately.
I've been thinking about it and I think I can do it without raycasting. I just need to figure out how to make the bot go from moving randomly in all directions to moving left and right towards the player when I shoot it. ^^
var x = randi_range(-1,1)
var z = randi_range(-1,1)
var dir = Vector3(x,0,z).normalized()
velocity = speed * dir
$RandomTimer.start_random()
if $"." take_damage():
$"." look_at(player.position)'''
The "look at" function doesn't seem to work, and besides, I don't even know how to tell it to look left and right in front of the player, since the player's position can change, so the left and right directions aren't always on the same axis. ^^