For now, i solve the main issue
var lock_enemy
var lock_enemy_check = 0
func _physics_process(delta):
if lock_enemy:
look_at(lock_enemy.translation,Vector3.UP)
if lock_enemy_check == 1:
rotate_speed = 3
func _on_Enemy_Detect_body_entered(body):
body = enemy1
var min_distance = 20
var instanced_enemies = get_tree().get_nodes_in_group("enemy")
if body == enemy1:
print ("enemy entered the area")
for close_enemy in instanced_enemies:
var distance = translation.distance_to(close_enemy.translation)
if (distance < min_distance):
lock_enemy = close_enemy
print ("close enemy : " +str(lock_enemy), "and dinstance from it: " +str(distance))
# look_at(lock_enemy.translation,Vector3.UP
lock_enemy_check = 1
else:
enemy1 = null
this is output:
https://streamable.com/8bgjog
as you can see, because of lock, and little collisions of between enemy and player, all of the objects on the scene goes of of their axis, is there a simple and clean way the fix this?. i mean i dont need collisions in this game, this will be top down, so all the objects need to be on the floor, not float around at the y axis.they will just shoot the eachother.
well maybe its because of my way of player controller mechanic, its roughly like this:
export var speed = -0.5
export var speed2= 0.5
var rotate_left
var rotate_right
var moveForward
var rotateValue
var moveBack
var rotate_speed = 0.2
func _physics_process(delta):
rotate_left = Input.is_action_pressed("left")
rotate_right = Input.is_action_pressed("right")
moveForward = Input.is_action_pressed("up")
moveBack = Input.is_action_pressed("down")
if rotate_left:
rotateValue = -speed * rotate_speed
rotate_y(rotateValue)
if rotate_right:
rotateValue = speed * rotate_speed
rotate_y(rotateValue)
if moveForward:
translate(Vector3(0,0,speed))
if moveBack:
translate(Vector3(0,0,speed2))
i will make this game for phones so i will add a joistic mechanic, because of that i will change the character movment mechanics too, but i need to know, that floating at the y axis thing happinig because of the movment of the player?
thank you for your time.