I have a very small scene, with a resting bat that flaps when its collision shape is entered, I want the bat to move in a random direction when it starts flapping, so when theres lots of instances of the bat in a main scene, the bats all fly off in different directions when the collision shape is entered by the player, but not sure where to start to implement this movement part.

Any pointers or ideas anyone?

The actual mechanics would go in the move() function, but this has to be passed back to the physics process function too? Im a bit lost!

func _physics_process(delta):
	pass

func _on_Area2D_body_entered(body):
	move()
	pass

func move():
	# fly away.....
	pass

At the moment I have a KinematicBody2d (for the movement?) for the main bat scene, with the Area2D as a child using its collision for the body_entered signal.

One easy way is to pick a random point on the screen, and then have the bat move to that position, then when it's close enough, pick another random point. It's kind of dumb AI, but for a bat it might be enough.

Sounds like a good way to do it actually!

Ok, I would have to do an if true statement in the process / physics_process function so that it actually calculated the movement at run time. (Kind of answering my own question here!! - wasnt sure how to actually get the movement running at first...)

2 years later