BEAT THEM ALL GAME - pb
Asked Answered
T

2

0

hi,
i make my beat them all game in 3d with 2d sprite, it's more easy for collision and jump but i got 2 problems because i tyry to recycle scriptsd who works on 2D and a problem with global_position.
1 - enemy go towards player

#ennemy goes to player
func _physics_process(delta):
if target:
var velocity = global_position.direction_to(target.global_position)
move_and_collide(velocity * SPEED * delta)
if animation == false:
$AnimatedSprite3D.play("Walk")

for detection
#ennemy detect player
func _on_detection_body_entered(body):
target = body
func _on_detection_body_exited(body):
target = null

it didn't work πŸ™‚ can you help me ?

2 - second problem, i want to make a flip en sprite enemy :
#flip H ennemy, ennemy turn towards the player
if global_position.x >= target.global_position.x :
$AnimatedSprite3D.flip_h = false
if global_position.x <= target.global_position.x :
$AnimatedSprite3D.flip_h = true

can you help me too ?

thx
cya

Thenceforth answered 18/3 at 11:8 Comment(0)
C
0

Hi there, I changed the tag to the more appropriate one as this is more about asking for help rather than a project. πŸ‘

Also please, also make sure your headers are in English so people (is it French?) can understand it. πŸ™‚

Croissant answered 18/3 at 15:36 Comment(0)
T
0

Croissant sorry i edit my post

Thenceforth answered 18/3 at 16:38 Comment(0)

© 2022 - 2024 β€” McMap. All rights reserved.