0 votes

Hey!

First of all, thank you dearly for opening up this question.

I'm trying to recreate pong and make it two player. It's for this reason that I decided to create one script - playerScript.gd - that handles the physics for both player1.gd and player2.gd, and then having different movement mappings between player 1 and 2.

I think the easiest way to show my problem is by adding the code.

~~~~

playerScript.gd

extends KinematicBody2D
class_name player

export var speed = 300

#func _process(delta):
#   pass

This is the script that I will eventually use to handle the collision detection for both players.

~~~~

player1.gd

extends player

# Declare member variables here. Examples:
# var a: int = 2
# var b: String = "text"

func _process(delta):
    var mov = Vector2()
    if Input.is_action_pressed("p1_up"):
        mov.y -= 1
    if Input.is_action_pressed("p1_down"):
        mov.y += 1

    mov = mov.normalized() * speed

    move_and_slide(mov)

moveandslide(mov) is highlighted RED with this error:

Line 7 (UNUSED_ARGUMENT):The argument 'delta' is never used in the function '_process'.

~~~~

Do I need to multiply something by the delta? I found that when I don't call the classname player, replace it with KinematicBody2D and include the speed variable in the player1.gd script, everything works fine and I'm able to move the player up and down.

The issue is this doesn't work when I try to call an external script.

What am I missing?

asked Oct 4, 2019 in Engine by boyilearn (12 points)

The error Line 7 (UNUSED_ARGUMENT):The argument 'delta' is never used in the function '_process'. isn't really an error; it's a warning. You can use the _process() function without using the delta parameter. The move_and_slide() function factors in delta, so you don't need to multiply it by anything.

I don't know what's the problem with your script, though. There does seem to be a problem with your inheritance of the "player" script. But I don't exactly know what.

1 Answer

0 votes

You should be able to inherit your playerScript class like this:

extends "playerScript.gd"

answered Oct 4, 2019 by Mikko (18 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.