vector3. Move object to object

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Oleg Poluhin
:warning: Old Version Published before Godot 3 was released.

Good day to all! I apologize for my English. Please tell me how to make the object move to another object when the button is clicked.
Attached a picture, for example, what you need to do.

http://joxi.ru/12M5DMdt4gZwq2

Tried to implement it this way:

var cc
func _input_event_enemy(viewport, event, clickPos, click_noraml, shape_idx):
	if event.type == InputEvent.MOUSE_BUTTON and event.button_index == BUTTON_LEFT and event.pressed:
		bullet()
		cc = clickPos

func _process(delta):
	get_node(bulCo).show()
	bul_pos = get_node(bulCo).get_translation() 
	bul_pos +=  Vector3(cc.x,-cc.y,cc.z) * 0.3 * delta
	get_node(bulCo).set_translation(bul_pos) 

func bullet():
	CountBullet = CountBullet + 1
	var bullet_inst = bullet.instance()
	bullet_inst.set_name("bullet"+str(CountBullet))
	add_child(bullet_inst)
	get_node("bullet"+str(CountBullet)).hide()
	get_node("bullet"+str(CountBullet)).set_translation(Vector3(get_node("/root/Main/PlayerEvent").get_translation()))
	return 

The object flies that up, then directly down if obj2 is next to obj1.

:bust_in_silhouette: Reply From: metin

To get a vector that points from bul_pos to cc you could do

var direction = cc - bul_pos
direction = direction.normalized()

Then you should be able to move it with

bul_pos +=  direction * 0.3 * delta

I might be wrong though, I’m new to Godot.

Big Thanks!!!

Oleg Poluhin | 2017-09-02 18:31