Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Rev7092 |
Im making a platformer game, and i already have an enemy using kinematicbody2d with his projectile using area2d node.
So, i wanted to make the player to be able to rotate and change the direction of the projectile from the enemy (reflecting) straight back at him by attacking the projectile. I really want to know how i can do this.
Heres my projectile code :
extends Area2D
var move = Vector2.ZERO
var look_vec = Vector2.ZERO
var player = null
var speed = 1
func _ready():
look_vec = player.position - global_position
func _physics_process(delta):
move = Vector2.ZERO
move = move.move_toward(look_vec,delta)
move = move.normalized() * speed
position += move