I'm creating tank game demo , in game i want enemy tank to always face toward the player tank.
I already check look_at() function but it will face immediately, i don't want that. I want enemy tank to slowly rotate toward player.
What i'hv done so fare is :
extends Node2D func _ready(): $Tank2.loadPlayer1($Tank1) pass
extends KinematicBody2D var rotSpeed = 0.3 var player1 var speed = 30 var velocity = Vector2() func _ready(): pass func loadPlayer1(obj): player1 = obj func _process(delta): if player1 != null: velocity = Vector2() var rot_dir = (player1.position - position).angle() rotation += rotSpeed*rot_dir * delta velocity = Vector2(0,0).rotated(rotation) move_and_slide(velocity) pass
My Result is : Enemy Tank (red) keep rotating
Does anyone know how do i fix this?