It won't work :(

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

I’m not very good at coding (I don’t know GDScript or C# at all but I want to make a video game). I used a YouTube tutorial to make an up-down shooter starting with movement. I’ll copy and paste the code for the movement here:

extends KinematicBody2D

var movespeed = 500

func _ready():
pass #Replace with function body.

***func physics_process(delta)*:**
var motion = Vector2()
if Input.is_action_pressed("up"):
	motion.y -= 1
	if Input.is_action_pressed("down"):
	motion.y += 1
	if Input.is_action_pressed("right"):
		motion.x += 1
if Input.is_action_pressed("Left"):
	motion.x -= 1
	
motion = motion.normalized()
motion = move_and_slide(motion * movespeed)
look_at(get_global_mouse_position())

Between the four stars is where I made an error, if you have a way of fixing this please put a comment.

“It won’t work” does not give any information. If you got an error, you should include exactly what the error says. If there’s no error but the code doesn’t do what you think it should do, please say what you want it to do so it’s possible to tell what’s wrong.

As it is, it looks like you may have an indentation problem but because of your copy and paste, it’s very hard to tell. Also, adding in asterisks just changes the code so if that line were wrong, it wouldn’t be possible to tell what’s wrong about it.

kidscancode | 2020-06-29 15:54

But what does the error says? afaik physics process function starts with an underscore, and doesnt end with a *, so changing physics_process(delta)*: by _physics_process(delta):? Also, have you checked correct indentation? Indentation in gdscript is mandatory

p7f | 2020-06-29 15:55