Godot Version
Godot_v3.5.3-stable_mono_win64
Question
Why am I getting a black screen when I start the game? That’s the base question, I’ll post what I get in my error log here:
E 0:00:04.947 get_node: (Node not found: “FloorCol” (relative to “Sprite”).)
<C++ Error> Method failed. Returning: nullptr
<C++ Source> scene/main/node.cpp:1476 @ get_node()
player1.gd:4 @ _init()
Here’s my node setup:
Scene:
Name: MoveScene
Project Type: 2D
Nodes:
Sprite_P1
Type: Sprite
Extends Class: KinematicBody2D
Sprite_P2
Type: Sprite
Extends Class: KinematicBody2D
Floor
Type: StaticBody2D
This is my current player script:
extends Sprite
var speed = 200 # Pixels per second
var floor_position = get_node("FloorCol").position.y # Get the floor's position when the game starts
func _process(delta):
var velocity = Vector2.ZERO
velocity.x = Input.get_action_strength("ui_right") - Input.get_action_strength("ui_left")
velocity.y = -Input.get_action_strength("ui_up") + Input.get_action_strength("ui_down")
# Limit downward movement
if position.y + velocity.y * delta >= floor_position:
position.y = floor_position
velocity.y = 0
position += velocity.normalized() * speed * delta
I haven’t added kinematic bodies yet in this session, but they’ll be put in once I solve this. I have had this issue both with and without them.
I’m very much a beginner, so if anyone has any tips I’d be very happy.