'Area2D' does not contain a 'Start' definition, and could not find an accessible 'Start' connection method that takes the type 'Area2D' as its first argument (possibility, missing using directive or assembly reference).
I'm guessing your player object has a class like Player (since that's how you add functions to existing node types).
Assuming that's the case...
when you do GetNode<Area2D>("Player") you get an Area2D reference. The object is really a Player, but the reference only knows about Area2D and therefore can't see the Start function.
Try changing the line to:
var player = GetNode<Player>("Player");
(or whatever your class is called)
I bet it’s Start with a lowercase s. Also I like how you used the free tag. Haha, free help.
Apprehensive Unfortunately, Start is written correctly (Maybe this will help to understand what the problem is?)
Up
You are calling start() on two separate nodes but I only see code implemented for one of those
I'm guessing your player object has a class like Player (since that's how you add functions to existing node types).
Assuming that's the case...
when you do GetNode<Area2D>("Player") you get an Area2D reference. The object is really a Player, but the reference only knows about Area2D and therefore can't see the Start function.
Try changing the line to:
var player = GetNode<Player>("Player");
(or whatever your class is called)
Area2D does not have any function called Start. Maybe your custom class, which inherits from Area2D does. But in that case, you need a reference to your class, not Area2D. In GDScript it's implicit, or you can define a name with class_name
. In C# it's probably defined when you inherit the class, but I don't know off hand cause I only use GDScript.
Goblet In C# it's probably defined when you inherit the class,
Yep. Here's the code I made as a test:
Parent object:
using Godot;
using System;
public class Base : Node2D
{
public override void _Ready()
{
var player = GetNode<Player>("Player");
player.Start();
}
}
Player object:
using Godot;
using System;
public class Player : Area2D
{
public override void _Ready()
{
}
public void Start()
{
}
}
Thanks everyone! Helped a lot, changed <Area2D> to <playercontroller> the name of the class that was written in the code
© 2022 - 2024 — McMap. All rights reserved.