Trying to make instanced player move using move_and_collide, but don't know how to call it.

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By JSands

Script is attached to a Tilemap for an instanced level. Not sure if the image helps. I have a player scene that gets instanced. I’m looking for the best way, after input is calculated here, to move the instanced player (aPlayer) using move_and_collide.

extends TileMap

onready var aPlayer = preload("res://Scenes/Player.tscn").instance()

var cSpawn1 = Vector2.ZERO

func _ready() -> void:
	aPlayer.position = cSpawn1

func _physics_process(delta) -> void:
	if Input.is_action_just_released("iPlayerInteract"):
		var vInputDirection = Vector2(Input.get_action_strength("iPlayerRight") - Input.get_action_strength("iPlayerLeft"), Input.get_action_strength("iPlayerDown") - Input.get_action_strength("iPlayerUp"))
		if vInputDirection != Vector2.ZERO:
			_Move(aPlayer, vInputDirection)

func _Interact():

func _Move(vSelf, vDirection):


:bust_in_silhouette: Reply From: magicalogic
vSelf.move_and_collide(vector2(0,200) * vDirection * delta)

The vector is for velocity forward (I assume your forward is +x) .
You can change it to suit your needs. Also your player has to be a kinematic body or other body with move and collide method and you also have to pass delta to the _Move method.