I am trying to attatch a player view as a child to a 2d node that holds my level 1 stage. If my player scrip is inheriting from Kenimatic2D I get the following error:
Error #1|: "Script inherits from native type 'KinematicBody2D', so it can't be instanced in object of type: 'Node2D'"
If I change my exstends constant to "Node2D" as it suggests, I receive this call back error:
Error #2|:"Parser Error: The method "moveandslide" isn't declared in the current class."
This is in reference to a function bellow which lies in the _process loop and is ment to handle movement. The function specified is the only one in documentation refering to it. Currently there is a method in the Vector2 class called "slide()" but It gives the same error as Error#2 but with the function in reference changed to "slide()"
Here is the code from PlayerScrt in the view hierarchy diagram below it:
-------GDscript-----------------------------------------------------
export (int) var speed = 200
var velocity = Vector2()
func getinput():
velocity = Vector2()
if Input.isactionpressed("right"):
velocity.x += 1
if Input.isactionpressed("left"):
velocity.x -= 1
if Input.isactionpressed("down"):
velocity.y += 1
if Input.isaction_pressed("up"):
velocity.y -= 1
velocity = velocity.normalized() * speed
func physicsprocess(delta):
getinput()
velocity = moveand_slide(velocity)
-----Veiw Hierarchy----------------------------------------
|
|Level 1_ []
|Player_ PlayerSript
|Kenimatic2D node |
|